1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Alexa サンプル発話がスロットのみの場合、発話の認識率を高めることができる

Last updated at Posted at 2021-03-04

はじめに

スロット値がめっちゃあるスキル(:closed_book: 中学一年の英単語)を作ってスキルストアに公開ところ、Amazonさんから発話の認識率が向上する改善の提案をいただいたのでメモ。

公開時のインテントとスロットの設定

公開当初は、こんな感じでインテントを作成していた。

  {
      "name": "AnswerIntent",
      "slots": [
          {
              "name": "Word",
              "type": "WordsList"
          }
      ],
      "samples": [
          "{Word}",
          "{Word} かな",
          "{Word} です",
          "えっと {Word}"
      ]
  },

認識率を向上させるには

上記のインテント設定に対して、下記のような提案をいただいた。

サンプル発話がスロットのみの場合、そのスロット独自のインテントを作成することで、発話の認識率を高めることができます。

どうやらサンプル発話がスロットのみのものがある場合は、スロットのみの単独インテントを作成すると認識率が上がるようだ。

ただ、公式ドキュメントにはインテントを分けることは記載されていないっぽい。あ、カスタムスロットとカスタムインテントの場合ということか。どこかに書いてあるのかもしれない。

image.png

JSON{word} と記述されている部分を別のインテントにするイメージ。

  {
      "name": "AnswerIntent",
      "slots": [
          {
              "name": "Word",
              "type": "WordsList"
          }
      ],
      "samples": [
          "{Word}",       ←--- これ ※発話がスロットのみ
          "{Word} かな",
          "{Word} です",
          "えっと {Word}"
      ]
  },

または Alexa Developer Console{word} と記述されている部分を別のインテントにするイメージ。

image.png

ハンドラーはこんな感じ。

index.js
const AnswerIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
        && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AnswerIntent';
    },
    async handle(handlerInput) {
      :
      :

どのように変更するのか

スロットのみの単独インテントを作る。そして、もともと作成していたインテントから発話がスロットのみの定義を削除する。これだけ。

JSON で記述する場合はこんな感じで設定する。

JSON
  {
      "name": "AnswerIntent",
      "slots": [
          {
              "name": "Word",
              "type": "WordsList"
          }
      ],
      "samples": [                 {Word}を削除
          "{Word} かな", 
          "{Word} です",
          "えっと {Word}"
      ]
  },
  {
      "name": "AnswerOnlyIntent",
      "slots": [
          {
              "name": "Word",
              "type": "WordsList"
          }
      ],
      "samples": [
          "{Word}"                ※発話がスロットのみのインテントを作る
      ]
  },

Alexa Developer Console ではこんな感じで設定する。

image.png
image.png

ハンドラーはこんな感じで、どっちのインテントも取れるように変更する。

index.js
const AnswerIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
        && (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AnswerIntent'
        || Alexa.getIntentName(handlerInput.requestEnvelope) === 'AnswerOnlyIntent');
    },
    async handle(handlerInput) {
      :
      :

おわりに

気のせいかもしれないが、なんとなく向上したような気がする。
公開したスキルのスロットの中で認識の精度がイマイチだったスロット値がいくつかあったが、高い確率で認識されるようになったように感じたため、試してみる価値ありです。

(2021/5/16 追記)書いてから何ヶ月か経過したが、絶対やった方がいい。やるとやらないとではかなり認識率が違う。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?