简体   繁体   English

Alexa Node js(alexa-app-server)response.say不输出语音

[英]Alexa node js (alexa-app-server) response.say not outputting speech

I've been having some trouble trying to output speech after getting data using request-reponse and processing it. 使用请求响应获取数据并对其进行处理后,尝试输出语音时遇到了一些麻烦。 For whatever reason in the callback function it wont output the text. 无论出于何种原因,它都不会输出文本。 The console.log(prompt) works yet it the response.say(prompt).shouldEndSession(false).send() doesn't. console.log(prompt)有效,但response.say(prompt).shouldEndSession(false).send()无效。 If you've any idea it'll be greatly appreciated. 如果您有任何想法,将不胜感激。

test.getNumberStatus(number, function(err, message) {
    console.log("In callback outside if statement");
    if (err == null) {
      console.log(message);
      response.say(message).shouldEndSession(false).send();
    } else {
      console.log("Error");
      rresponse.say(message).shouldEndSession(false).send();
    }
  });

stopInfo.prototype.getStopStatus = function(stopNumber, callback) {
  var options = {
  method: 'GET',
  uri: ENDPOINT + '?stopid=' + stopNumber + '&maxresults=1&format=json',
  json: true
};

requestPromise(options).then(function(stopStatusObject) {
if (true) { // check if error from dublin bus
  console.log(stopStatusObject);

  var template = _.template('busstopinfo <%= error %>');
  var message = template({
      'error': 'test'
  });
  callback(null, message);
}
}).catch(function(err) {
var message = "I didn\'t have data for stop number " + stopNumber;
callback(err, message);
});
};

I had a similar situation and found out resolve automatically sends your output which works for sync but not for async. 我有类似的情况,发现解析会自动发送您的输出,该输出适用于同步,但不适用于异步。 Put add response.resolve in your troubled function to see if value is set to true before send() . 将add response.resolve放入有问题的函数中,以在send()之前查看value是否设置为true。 If it is you already used the promise. 如果是,您已经使用了诺言。 I corrected mine by putting return in front of function name, following Asynchronous Handlers Example section from here 我通过在此处的“异步处理程序示例”部分中将return放在函数名称之前来纠正了我的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM