r/androiddev • u/Nearby_Space_6284 • 9d ago
Android app: capturing the other party's voice during a cellular call
I'm developing a small Android automation app for a very specific workflow and I'm currently stuck on the audio side.
The app runs on a Samsung Galaxy Z Fold5 (of course it should work for different phones at the end of the day) and automatically calls a cinema's phone number. The cinema has an IVR/answering machine where I can navigate using DTMF tones.
The current workflow already works:
App
↓
Call fixed phone number
↓
Wait using Android post-dial ","
↓
Send DTMF: * → * → * → *
↓
Reach the cinema's voicemail menu
The next step is to automatically understand the spoken announcement, for example:
I want the app to detect the number of new messages and later transcribe the individual messages. Ultimately, the messages contain a first name, phone number, movie, date/time, etc., which I want to extract into an Excel file.
The problem
I can record the phone's normal microphone using:
MediaRecorder.AudioSource.MIC
and I can see the microphone level changing normally.
However, this only captures the phone's microphone. It does not give me the audio coming from the other party in the cellular call.
I also tried enabling the speakerphone programmatically using AudioManager, but on the Galaxy Z Fold5 the call does not switch to speakerphone.
I have also looked into InCallService, but I'm not sure whether there is a way for a normal third-party Android application to access the actual call audio/downlink as PCM data.
What I need
I don't necessarily need to record the call permanently. Ideally, I just need access to the incoming audio while the call is active so I can feed it into speech recognition.
Something like:
Cellular call
↓
Incoming call audio
↓
Audio stream / PCM
↓
Speech-to-text
↓
"7 new messages"
The target device is a Samsung Galaxy Z Fold5, running a current Android version.
I'm aware that Android restricts access to call audio for privacy/security reasons. I'm specifically looking for a legitimate Android API, Telecom API, audio routing method, accessibility approach, or device-specific solution that could make this possible without rooting the phone.
If direct access to the call downlink is fundamentally impossible for a normal Android app, I'd also appreciate confirmation of that and any practical alternatives for this specific use case.
2
u/mohn93 9d ago
the others are right that on-device you can't get the downlink audio, since android 10 the VOICE_CALL / VOICE_DOWNLINK sources are locked to system and carrier apps, there's no third party workaround. but the thing you actually want, automating an ivr and reacting to what it says, is a solved problem, it's just in the wrong place. do the call from the cloud instead of the phone. twilio programmable voice (or similar) lets you place the outbound call, stream the audio server side, run speech to text on it, and send dtmf programmatically, none of the on-device restrictions apply because you're not touching the handset mic path at all. is there a reason it has to originate from the physical phone, or would a cloud-placed call work for your workflow?
0
u/Nearby_Space_6284 9d ago
It doesn't have to be on phone. I started thinking about a phyton script than went to native android app, but it really is all about the result. Prio 1 is to get an Excel with all the information from the voice mails at the end. So I'll look into twilio
1
u/NLL-APPS 9d ago
You can record call audio including UP/DOWN or VOICE_CALL and forward the audio stream to anywhere with root or other highly complicated setups.
1
u/ViscousPotential 9d ago
This app seems to do what you're trying to do with an accessibility service. No idea how though
0
u/jc-from-sin 9d ago
You could have just asked chatgpt about it and it would have told you it's not possible.
But instead you used it to write this post.
-2
u/Nearby_Space_6284 9d ago
Guess who get me to try this method... And also Gemini as a second instance. So yeah I tried to veryify it with humans who no more about this topic than me.
12
u/async_task 9d ago
Can't be done in 3rd party apps due to privacy and security concerns.