将 Alexa AMAZON.NUMBER 转换回数字词(“五”)以便 Alexa 可以说出来
Convert Alexa AMAZON.NUMBER back to numeric word (“five”) so it can be spoken by Alexa
Alexa Skill Kit (ASK) 内在意图 "AMAZON.NUMBER",将数字词(“五”)转换为数字(例如“5”)。如何将 Alexa AMAZON.NUMBER 转换回数字词(“五”)以便 Alexa 可以说出来?
正在尝试:
"CheckNumberIntent": function (intent, session, response) {
var numberSlot = intent.slots.Number,
numberName;
speech = "Dude you said" + numberSlot + "we should hang out";
var speechOutput = {
speech: speech,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.tellWithCard(speechOutput, "Greeter", "Hello World!");
这导致:
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "Dude you said[object Object]we should hang out"
},
numberSlot
是一个对象,这就是您在输出中看到 [object Object]
的原因。 Per the doc 您需要引用 value
成员。此外,您需要在数字周围添加空格,否则您最终会得到
Dude you said5we should hang out
这是更正后的代码:
"CheckNumberIntent": function (intent, session, response) {
var numberSlot = intent.slots.Number,
numberName;
speech = "Dude you said " + numberSlot.value + " we should hang out";
var speechOutput = {
speech: speech,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.tellWithCard(speechOutput, "Greeter", "Hello World!");
Alexa Skill Kit (ASK) 内在意图 "AMAZON.NUMBER",将数字词(“五”)转换为数字(例如“5”)。如何将 Alexa AMAZON.NUMBER 转换回数字词(“五”)以便 Alexa 可以说出来?
正在尝试:
"CheckNumberIntent": function (intent, session, response) {
var numberSlot = intent.slots.Number,
numberName;
speech = "Dude you said" + numberSlot + "we should hang out";
var speechOutput = {
speech: speech,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.tellWithCard(speechOutput, "Greeter", "Hello World!");
这导致:
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "Dude you said[object Object]we should hang out"
},
numberSlot
是一个对象,这就是您在输出中看到 [object Object]
的原因。 Per the doc 您需要引用 value
成员。此外,您需要在数字周围添加空格,否则您最终会得到
Dude you said5we should hang out
这是更正后的代码:
"CheckNumberIntent": function (intent, session, response) {
var numberSlot = intent.slots.Number,
numberName;
speech = "Dude you said " + numberSlot.value + " we should hang out";
var speechOutput = {
speech: speech,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.tellWithCard(speechOutput, "Greeter", "Hello World!");