如何在使用 Twilio 拨号时以编程方式实时操纵语音?
我有一个小的 Twilio 应用程序,每当使用我的个人号码(例如 +1111111)呼叫我的 Twilio 号码(例如 +22222222)时,它都会呼叫真实的电话号码(例如 +3333333)。我使用以下 Twilio 函数来实现此功能:
exports.handler = (context, event, callback) => {
const twiml = new Twilio.twiml.VoiceResponse();
twiml.dial("+3333333");
return callback(null, twiml);
};
现在,当 +3333333 的所有者拿起他的电话时,呼叫者 (+1111111) 和目标 (+3333333) 之间就会建立呼叫连接。
如何在呼叫者 (+1111111) 或目标 (+3333333) 说话时运行一个函数来实时拦截此呼叫中的语音,以执行诸如改变声音、过滤脏话等操作?
我尝试在 Twilio 函数中使用
和
TwiML 动词,但这些动词只会在通话结束或挂断后才会触发。
I have a small Twilio app that calls a real phone number (e.g. +3333333) whenever my Twilio number (e.g. +22222222) is called using my personal number (e.g. +1111111). I implement this using the following Twilio function:
exports.handler = (context, event, callback) => {
const twiml = new Twilio.twiml.VoiceResponse();
twiml.dial("+3333333");
return callback(null, twiml);
};
Now when the owner of +3333333 picks up his phone, a call connection is established between the caller (+1111111) and the target (+3333333).
How can I intercept speeches in this call, in real-time, by running a function whenever either the caller (+1111111) or the target (+3333333) speaks, to do things such as changing voice, filtering profanity, etc?
I have tried using <Gather>
and <Say>
TwiML verbs in my Twilio function but these will only get triggered after the call has ended or hung up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您现在实际上可以使用 Twilio 实现这一目标。您可以使用
接收和发送音频流
TwiML。
允许您通过 Websocket 连接实时接收音频并将音频发送到呼叫。要更改其间的音频,您需要将呼叫者仅连接到
,而不是彼此连接,并通过 Websocket 和您想要的任何处理中继来自一个呼叫的音频做它,然后通过 websocket 连接到其他调用(反之亦然)。我没有关于如何做到这一点的更多信息,因为我还没有看到它完成。但这在理论上是可能的。
You can actually achieve this with Twilio now. You can receive and send audio streams using the
<Connect><Stream>
TwiML.<Stream>
allows you to receive and send audio to the call over a websocket connection in real time.To change the audio in between, you would want to connect the callers just to the
<Stream>
, not to each other, and relay the audio from one call, through the websocket and whatever processing you want to do to it, and then out through the websocket connected to the other call (and vice versa).I don't have more information on how to do that, as I've not seen it done. But it's possible in theory.