import com.twilio.twiml.voice.Gather;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.Say;
import com.twilio.twiml.TwiMLException;
public class Example {
public static void main(String[] args) {
Say say = new Say
.Builder("Welcome to Twilio, please tell us why you're calling").build();
Gather gather = new Gather.Builder().input("speech")
.action("/completed").say(say).build();
VoiceResponse response = new VoiceResponse.Builder().gather(gather)
.build();
try {
System.out.println(response.toXml());
} catch (TwiMLException e) {
e.printStackTrace();
}
}}
在上面的代码中,我想知道action method.what的功能是在action方法中使用"/completed“。
在“twilio医生”中,它说了一些类似的事情
“这个TwiML创建了一个with语音。当Twilio执行这个TwiML时,应用程序将提示用户并接受长达60秒的语音。一旦来电者停止讲话5秒,Twilio将把她转录的演讲发送到动作网址。”
我从下面的链接获得了上面的代码
发布于 2018-06-04 04:56:07
嘿我找到答案了。
我们可以提供任何公共网址并替换"/completed“。
这意味着一旦演讲者发言完毕,twilio将向该网址发送一个帖子请求。这个帖子请求体包含了twilio从演讲者那里捕捉到的内容。
下面是一个例子。
聚集集=新Gather.Builder().input(Gather.Input.SPEECH).timeout(10).action("http://0838a6b6.ngrok.io/asr/test").speechTimeout("auto").say(say).language(Gather.Language.EN_US).build();
这里http://0838a6b6.ngrok.io/asr/test = localhost:1234/asr/test
您可以从这里下载ngrok。
它将给您一个公共url到您的服务器上的特定端口。
希望这能帮上忙。谢谢
https://stackoverflow.com/questions/50054697
复制相似问题