/ /一致のためのさまざまな発声のテスト - alexa、alexa-skills-kit、alexa-skill

alexa、alexa-skills-kit、alexa-skillの異なる発話をテストします。

私はAmazon Echoのプログラミングが初めてです。 Node.jsを使用していて、名前の発話に基づいて異なる応答を返そうとしています。

例えば、私が "David"、 "James"、または "Benjy"という名前を言う場合、Alexaは単に "Welcome [そして私が言った名前]"と言うべきですが、 "Jonathan"と言うと "Yay!Welcome home Jonathan"と言うべきです。

しかし、私が "Jonathan"と言うとき、それは単に "Welcome Jonathan"と言うだけです。

私は基本的なalexa-skills-kit-color-expert Lambdaを修正し、そしてそのコードのsetColorInSession()関数を修正しました。その関数の名前をsetAndWelcomePerson()に変更しました。

私が試してみました:

  1. if文を使用して私の発話をテストし、Alexaが私の発話に基づいて返信するようにします。
  2. ある名前と次の名前を区別するようにAlexaに教えることを試みるためのさまざまな発話例を挙げます。

これはどれもうまくいかないようです。私が何をしているのか、修正すべきことを教えてください。

私のLambdaコードのsetAndWelcomePerson()関数:

 /**
* Sets the name of the person(s) and welcomes them.
*/
function setAndWelcomePerson(intent, session, callback) {
var cardTitle = intent.name;
var whoToGreetSlot = intent.slots.Person;
var repromptText = null;
var sessionAttributes = {};
var shouldEndSession = false;
var speechOutput = "";

if (whoToGreetSlot) {
var whoToGreet = whoToGreetSlot.value;
sessionAttributes = createWhoToGreetAttributes(whoToGreet);
if (whoToGreet === "Jonathan") {
speechOutput = "Yay! Welcome home " + whoToGreet + "!";
} else {
speechOutput = "Welcome " + whoToGreet + ".";
}

} else {
speechOutput = "I"m not sure who you want me to welcome. Please try again.";
}

callback(sessionAttributes,
buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
}

私の意図のスキーマ:

{
"intents": [
{
"intent": "WhoShouldBeGreeted",
"slots": [
{
"name": "Person",
"type": "LITERAL"
}
]
},
{
"intent": "AdditionalGreetingRequest",
"slots": []
}
]
}

私のサンプル発話:

WhoShouldBeGreeted {Sam and Cat|Person}
WhoShouldBeGreeted {Jonathan|Person}
WhoShouldBeGreeted {James|Person}
WhoShouldBeGreeted {Benji|Person}
WhoShouldBeGreeted welcome {Sam and Cat|Person}
WhoShouldBeGreeted welcome {Jonathan|Person}
WhoShouldBeGreeted welcome {James|Person}
WhoShouldBeGreeted welcome {Benji|Person}

ご協力ありがとうございました。

回答:

回答№1は2

あなたは "LITERAL"スロットタイプを使用しています。 (これはお勧めできませんが、まだサポートされています。)つまり、単語を認識しているだけです。話されている言葉には意味がありません。しかし、Javascriptの===演算子は大文字と小文字を区別します。あなたがあなたのログをチェックするならば、私はあなたが「ジョナサン」と言うときあなたが得るものは「ジョナサン」であると思う、そしてそれはあなたのマッチが失敗すると思う。

これを修正するには、比較を小文字に変更するか、演算子を大文字と小文字を区別しない文字列比較に変更します。 ここに)。

もう1つの方法は、LITERALスロットタイプを使用せず、代わりにAMAZON.US_FIRST_NAMEを使用することです。これは名前であることがわかっているので、大文字で返します。