Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Alexa询问回应onLaunch:演讲和重新演讲的预期行为是什么?_Java_Alexa_Alexa Skills Kit - Fatal编程技术网

Java Alexa询问回应onLaunch:演讲和重新演讲的预期行为是什么?

Java Alexa询问回应onLaunch:演讲和重新演讲的预期行为是什么?,java,alexa,alexa-skills-kit,Java,Alexa,Alexa Skills Kit,在使用echo测试我的技能时,我经历了以下行为: 由非意图请求和此响应调用时: public SpeechletResponse onLaunch(LaunchRequest request, Session session) throws SpeechletException { PlainTextOutputSpeech speech = new PlainTextOutputSpeech(); speech.setText("Welcome"); PlainTex

在使用echo测试我的技能时,我经历了以下行为:

由非意图请求和此响应调用时:

public SpeechletResponse onLaunch(LaunchRequest request, Session session) throws SpeechletException {
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText("Welcome");

    PlainTextOutputSpeech repromtSpeech = new PlainTextOutputSpeech();
    speech.setText("Repromt");
    Reprompt reprompt = new Reprompt();
    reprompt.setOutputSpeech(repromtSpeech);

    SimpleCard card = new SimpleCard();
    card.setTitle("Welcome");
    card.setContent("Test");

    return SpeechletResponse.newAskResponse(speech, reprompt, card);
}
Alexa只输出repromt文本

实际的互动是:

  • 用户:alexa询问“技能”
  • Alexa:重述“等待回答”
我期望/想要的互动是:

  • 用户:alexa询问“技能”
  • 欢迎“等待回答”
  • 用户:“没有正确响应”
  • Alexa:重述“等待回答”

我怎样才能获得预期的行为?如果响应中没有(从来没有?)包含语音文本,那么语音文本的作用是什么?

我认为您的代码中有错误。您正在设置speech.setText两次。我想你是想第二次设置repromptSpeech.setText。

哦,不,真的是那个打字错误;-)我甚至把它复制到这里简化的示例中。