问题
I am using Twilio Voice SDK on android to initiate a call to a normal phone number.
I need to be able to detect from within the app that initiated the call that the person on the phone pressed one of the keypad keys.
I cannot find a counterpart in the Voice SDK to call.sendDigits() for detecting DTMF tones.
I have tried a couple of approaches and am thinking of a third:
The most obvious approach was to find an api call for registering a listener to DTMF or a listener to Digits but I cannot find one.
NOTE: in my tests I noticed that when I send DTMF tones from the phone to the android device, I can hear abbreviated tones in the android device so Twilio seems to be processing the tones and letting through a modified version of them.The second approach was to find a library that could detect the tones from the audio stream and I found several posts that point to the Goertzel algorithm. I found a library (TarsosDSP) that implements the algorithm and seems easy to use. However, I cannot figure out how to get a hold of the audio stream from the twilio call.
The third approach (I have not tried yet because it seems too hacky... but I might get desperate enough) is to use twiml to detect the tones on the twilio server (using the Gather verb)... I will need to figure out how to have twilio listen in on an active conversation and then figure out how to have the twiml send a signal to my android device once it detects the DTMF.
It seems likely that Twilio does have a mechanism to register a listener to DTMF tones in the SDK and that I'm just not looking in the right places... that would be the best solution.
来源:https://stackoverflow.com/questions/56207669/how-to-detect-dtmf-tones-in-twilios-android-sdk