はじめに
ある日、ASK CLI コマンド リファレンスをぼーっと眺めていたら
( ゚ ρ ゚ )・・・あれっ、なんか前と少し違う気がする
何気なく、以下を見ていたら
Simulates an invocation of your skill with text input. Under the hood, the command calls ask api simulate-skill and continues polling for the simulation status until it is finalized. The parameters are the same as for ask api simulate-skill.
( ゚ ρ ゚ )・・・シミューレート早く日本語で使えるようにならないかなぁ。。。んっ…?
--locale, -l
Optional if ASK_DEFAULT_DEVICE_LOCALE environment variable is set, otherwise, required. Locale for the skill to be simulated. Valid values are en-US, en-GB, en-CA, en-AU, en-IN, de-DE, or ja-JP. If not specified, you will be prompted to enter the locale.
(つд⊂)ゴシゴシ
ja-JP
(;゚д゚) ・・・日本語で使えるだと…
私の当てにならない記憶では、ja-JP
はサポートされてませんと載っていたと記憶しています。
もしかしたら、かなり前から使えたかもしれません。
というわけで使ってみました。
とりあえず使ってみる
ask simulate --profile ask-profile-staging --skill-id amzn1.ask.skill.xxxx --locale ja-JP --text "じゃらじゃらを開いて"
{
"id": "xxxxx",
"status": "SUCCESSFUL",
"result": {
"skillExecutionInfo": {
"invocationRequest": {
"endpoint": "arn:aws:lambda:ap-northeast-1:xxxxx",
"body": {
"version": "1.0",
"session": {
"new": true,
"sessionId": "amzn1.echo-api.session.xxxxx",
"application": {
"applicationId": "amzn1.ask.skill.xxxxx"
},
"user": {
"userId": "amzn1.ask.account.xxxxx"
}
},
"context": {
"Display": {},
"System": {
"application": {
"applicationId": "amzn1.ask.skill.xxxxx"
},
"user": {
"userId": "amzn1.ask.account.xxxxx"
},
"device": {
"deviceId": "amzn1.ask.device.xxxxx",
"supportedInterfaces": {
"AudioPlayer": {},
"Display": {
"templateVersion": "1.0",
"markupVersion": "1.0"
}
}
},
"apiEndpoint": "xxxxx",
"apiAccessToken": "xxxxx"
}
},
"request": {
"type": "LaunchRequest",
"requestId": "",
"timestamp": "2018-04-30T00:27:07Z",
"locale": "ja-JP",
"shouldLinkResultBeReturned": false
}
}
},
"invocationResponse": {
"body": {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": " 点数を教えてと言ってください。 "
},
"reprompt": {
"outputSpeech": {
"type": "SSML",
"ssml": " 親の20符3翻の点数を教えてと言ってください。 "
}
},
"shouldEndSession": false
},
"sessionAttributes": {},
"userAgent": "ask-nodejs/1.0.25 Node/v6.10.3"
}
},
"metrics": {
"skillExecutionTimeInMilliseconds": 127
}
}
}
}
おぉ…返ってくる!
本投稿では、リクエストした結果からresult.skillExecutionInfo.invocationResponse.body.response.outputSpeech.ssml
の結果を出力するまでがゴールです。
シナリオテスト
シナリオテストなんて書いてますが、凝ったことはしていません。
まずは、ASK CLI
に食わせる会話をテキストに書き込んでいきます。
シナリオの作成
じゃらじゃらを開いて
ストップ
じゃらじゃらで子の点数を教えて
20
リャン
これをask simulate
コマンドの--text
オプションに渡していきます。
simulate
コマンドの実行
ask simulate
に前項で作成したテキストを渡すため、以下のコマンドを使用します。
- cat
- xargs(テキストの会話を
--text
オプションに渡す) - sed(結果を加工 タグの除去など)
- jq
環境に合わせて以下を設定してください。
- プロファイル名
- スキルID
: > simulate-result-staging.log
cat conversation-staging.txt \
| xargs -n 1 -J % ask simulate --profile ask-profile-staging --skill-id amzn1.ask.skill.xxxx --locale ja-JP --text % \
| jq -r .result.skillExecutionInfo.invocationResponse.body.response.outputSpeech.ssml \
| sed -e 's/<[^>]*>//g' | sed 's/^[ \t]*//' >> simulate-result-staging.log
シミュレート結果
結果はこんな感じです。
点数を教えてと言ってください。
また、呼んでくださいね!
null
null
20符2翻の点数は、ツモは親が700点、子が400点です。
ダイアログモデルを利用しているため、スロット収集中はoutputSpeech
部分は結果が返ってきません。
そのため、null
が出力されています。
今後拡張していきたいなぁと思います。
まとめ
simulate
コマンドを使って、シナリオテストを行いました。
実機で確認する前に、単体テスト、機能テストさらにsimulate
コマンドでシナリオテストをすることで事前に問題が見つけやすくなりますね!
余談
simulate
コマンドの日本語対応はいつされたんでしょうね・・・?
Change Log
からはわかりませんでした。。。
ドキュメント(英語!)は細かくチェックしましょう!