【问题标题】:Twilio speech recognition <gather>?Twilio 语音识别<收集>?
【发布时间】:2018-06-04 12:56:07
【问题描述】:
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方法的功能。action方法里面的“/completed”有什么用。

在 twilio 文档中它说这样的话

“此 TwiML 创建一个语音。当 Twilio 执行此 TwiML 时,应用程序将提示用户并接受最多 60 秒的语音。一旦呼叫者停止说话 5 秒钟,Twilio 会将她转录的语音发布到操作 url 。”

我从下面的链接得到了上面的代码

https://www.twilio.com/docs/voice/twiml/gather

【问题讨论】:

    标签: java speech-to-text twilio-api dialogflow-es


    【解决方案1】:

    嘿,我找到了答案。

    我们可以提供任何公共网址并替换“/完成”。

    这意味着一旦演讲者说完,twilio 将向该 url 发送一个 post 请求。该帖子请求正文包含 twilio 从扬声器中捕获的内容

    这是一个例子。

    Gather gather = new 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

    你可以从here下载ngrok

    它将为您提供一个指向您服务器上特定端口的公共 URL。

    希望这有帮助。 谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-19
      • 1970-01-01
      • 1970-01-01
      • 2021-05-19
      • 1970-01-01
      • 2022-11-14
      • 1970-01-01
      • 2019-06-19
      相关资源
      最近更新 更多