音声入力を使用してボットをテストする (AWS CLI) - Amazon Lex V1

Amazon Lex V2 を使用している場合は、代わりに Amazon Lex V2 ガイドを参照してください。

 

Amazon Lex V1 を使用している場合は、ボットを Amazon Lex V2 にアップグレードすることをお勧めします。V1 には新機能を追加されませんので、すべての新しいボットには V2 を使用することを強くお勧めします。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

音声入力を使用してボットをテストする (AWS CLI)

音声ファイルを使用してボットをテストするには、PostContent オペレーションを使用します。音声ファイルは、Amazon Polly テキスト読み上げ機能のオペレーションを使用して生成します。

この演習のコマンドを実行するには、Amazon Lex および Amazon Polly コマンドが実行されるリージョンを確認しておく必要があります。Amazon Lex のリージョンのリストについては「ランタイム Service Quotas」を参照してください。Amazon Polly でサポートされているリージョンとエンドポイントの一覧については、Amazon Web Services 全般のリファレンスの「AWS リージョンとエンドポイント」を参照してください。

注記

次の AWS CLI の例は、Unix、Linux、および macOS 用にフォーマットされています。Windows の場合は、"\$LATEST"$LATEST に変更し、各行末のバックスラッシュ (\) 連結文字をキャレット (^) に置き換えてください。

音声入力を使用してボットをテストするには (AWS CLI)
  1. AWS CLI で、Amazon Polly を使用して音声ファイルを作成します。例は、Unix、Linux、および macOS 用にフォーマットされています。Windows の場合は、各行末のバックスラッシュ (\) Unix 連結文字をキャレット (^) に置き換えてください。

    aws polly synthesize-speech \ --region region \ --output-format pcm \ --text "i would like to order flowers" \ --voice-id "Salli" \ IntentSpeech.mpg
  2. 音声ファイルを Amazon Lex に送信するには、次のコマンドを実行します。Amazon Lex は、レスポンスの音声を指定の出力ファイルに保存します。

    aws lex-runtime post-content \ --region region \ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --content-type "audio/l16; rate=16000; channels=1" \ --input-stream IntentSpeech.mpg \ IntentOutputSpeech.mpg

    Amazon Lex は、レスポンスで最初のスロットをリクエストします。音声レスポンスは指定の出力ファイルに保存されます。

    {
        "contentType": "audio/mpeg", 
        "slotToElicit": "FlowerType", 
        "dialogState": "ElicitSlot", 
        "intentName": "OrderFlowers", 
        "inputTranscript": "i would like to order some flowers", 
        "slots": {
            "PickupDate": null, 
            "PickupTime": null, 
            "FlowerType": null
        }, 
        "message": "What type of flowers would you like to order?"
    }
  3. バラの花束を注文するには、次の音声ファイルを作成して Amazon Lex に送信します。

    aws polly synthesize-speech \ --region region \ --output-format pcm \ --text "roses" \ --voice-id "Salli" \ FlowerTypeSpeech.mpg
    aws lex-runtime post-content \ --region region \ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --content-type "audio/l16; rate=16000; channels=1" \ --input-stream FlowerTypeSpeech.mpg \ FlowerTypeOutputSpeech.mpg
  4. 配達日を設定するには、次の音声ファイルを作成して Amazon Lex に送信します:

    aws polly synthesize-speech \ --region region \ --output-format pcm \ --text "tuesday" \ --voice-id "Salli" \ DateSpeech.mpg
    aws lex-runtime post-content \ --region region \ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --content-type "audio/l16; rate=16000; channels=1" \ --input-stream DateSpeech.mpg \ DateOutputSpeech.mpg
  5. 配送時間を設定するには、次の音声ファイルを作成して Amazon Lex に送信します:

    aws polly synthesize-speech \ --region region \ --output-format pcm \ --text "10:00 a.m." \ --voice-id "Salli" \ TimeSpeech.mpg
    aws lex-runtime post-content \ --region region \ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --content-type "audio/l16; rate=16000; channels=1" \ --input-stream TimeSpeech.mpg \ TimeOutputSpeech.mpg
  6. 配達を確認するには、次の音声ファイルを作成して Amazon Lex に送信します。

    aws polly synthesize-speech \ --region region \ --output-format pcm \ --text "yes" \ --voice-id "Salli" \ ConfirmSpeech.mpg
    aws lex-runtime post-content \ --region region \ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --content-type "audio/l16; rate=16000; channels=1" \ --input-stream ConfirmSpeech.mpg \ ConfirmOutputSpeech.mpg

    配達を確認すると、Amazon Lex からインテントの達成を確認するレスポンスが送信されます。

    {
        "contentType": "text/plain;charset=utf-8", 
        "dialogState": "ReadyForFulfillment", 
        "intentName": "OrderFlowers", 
        "inputTranscript": "yes", 
        "slots": {
            "PickupDate": "2017-05-16", 
            "PickupTime": "10:00", 
            "FlowerType": "roses"
        }
    }
    

次のステップ

演習 2: 新しい発話を追加する (AWS CLI)