如何在 twilio 中同时播放和录制语音 [英] How to play and record voice at same time in twilio

查看:37
本文介绍了如何在 twilio 中同时播放和录制语音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 twilio

I was working with twilio

我的情况是当用户拨打电话时,IVR 会询问用户心情,然后开始录音 10 秒,将该录音带到服务器,根据用户心情查找播客,然后将 TWIML 与播客 mp3 一起发回url 并播放给用户

my case is when user make a call IVR will ask for user mood and then start recording for 10 second, take that recording to server find podcast according to user mood and send back TWIML with podcast mp3 url and play it to user

我已经完成了这项工作

现在我想实现这样一个功能,当用户说跳过"或我不喜欢这个请跳过"(或类似的东西,我会用Ai处理)停止播放并转到服务器并获取另一个播客 mp3 网址并播放

now i want to implement the feature in which when user user say "Skip" or "I don't like this one please skip"(or something similar which i will handle with Ai) immediately stop playing and goto server and get another podcast mp3 url and play it

为了做到这一点,我需要做这样的事情:

for doing this i need to do something like this:

<?xml version="1.0" encoding="UTF-8" ?>  
<Response> 
    <Play>https://somechannel.com/podcast.mp3</Play>
    <record action='/voice/check-what-user-said'></record>
</Response>

但是这样做并不能解决我的问题,因为 twilio 会在播放完毕后开始录制,我想每 10 秒录制一次并在用户收听播客时连续发送到服务器

but doing this will not solve my problem because twilio will start recording after finish playing, I want to record each 10 seconds and send it to server continuously when user is listening podcast

let say, twilio start playing mp3, it also start recording

e.g:
playing 
00:00 - start recording for ten seconds
00:10 - finish recording and send it to server
00:11 - start another recording for 10 seconds
00:20 - finish recording and send it to server

每次我们在服务器上进行录音时,我会将录音转换为文字广告检查用户是否说跳过",如果是,我将即时修改通话

each time when we get recording on server, i will convert recording to text ad check if user said "skip", if yes i will modify call on the fly

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

恐怕目前无法*在播放 mp3 的同时录制通话片段.

I'm afraid that it is currently not possible* to record slices of a call while simultaneously playing an mp3.

我可以建议您使用按键代替语音吗?这个功能呢?然后您可以使用以下 TwiML(作为示例)

Can I suggest that rather than voice you use a key press for this functionality instead? You can then use the following TwiML (as an example)

<?xml version="1.0" encoding="UTF-8" ?>  
<Response> 
  <Say>Press any digit to skip this podcast</Say>
  <Gather action="/voice/check-digits" numDigits="1">
    <Play>https://somechannel.com/podcast.mp3</Play>
  </Gather>
</Response>

然后,您的应用程序中将需要一个位于 /voice/check-digits 的端点,用于将用户引导至下一个播客.

Then you will need an endpoint in your application at /voice/check-digits that directs the user onto the next podcast.

*好的,如果您将音频播放到会议中并让另一个脚本拨入会议并录制 10 秒钟,然后在另一个脚本拨入开始录制时挂断,则可能是可行的.但即便如此,您还是会尝试从播客的音频中提取来电者的声音,这根本不可能准确.特别是如果播客中的声音说跳过".所以我还是推荐使用 !

*OK, it might be possible if you play the audio into a conference and have another script dial into the conference and record 10 seconds, then hangup as another script dials in to start recording. But even then, you'd be trying to extract the voice of the caller from the audio of the podcast and that is unlikely to be accurate at all. Especially if a voice in the podcast says "skip". So I still recommend using <Gather>!

这篇关于如何在 twilio 中同时播放和录制语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆