How to detect DTMF tones in Twilio's android sdk

别说谁变了你拦得住时间么 提交于 2020-02-07 02:36:14

问题


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:

  1. 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.

  2. 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.

  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!