1

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

たとえば、「David」、「James」、または「Benjy」という名前を言うと、Alexa は「Welcome [and the name I said]」とだけ言う必要がありますが、「Jonathan」と言うと、「Yay! Welcome home 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}

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

4

1 に答える 1

3

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

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

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

于 2016-07-16T18:13:20.630 に答える