2. 音声認識

mimi ASR のスタートガイドです。
mimi の音声認識サービスを利用できるようになるまでの手順をまとめています。

Step1 : 事前準備

1. アクセストークンの取得

1. トークンの取得を実行して、アクセストークンを取得してください。この際、音声認識サービスが実行できるようスコープの指定を行い、アクセストークンを払い出すよう注意して下さい。

  • 参考:音声認識サービスの URI
    • https://apis.mimi.fd.ai/auth/asr/http-api-service
    • https://apis.mimi.fd.ai/auth/asr/websocket-api-service
    • https://apis.mimi.fd.ai/auth/google-asr/http-api-service
    • https://apis.mimi.fd.ai/auth/google-asr/websocket-api-service
    • https://apis.mimi.fd.ai/auth/nict-asr/http-api-service
    • https://apis.mimi.fd.ai/auth/nict-asr/websocket-api-service

2. 音声認識用のサンプルファイルの取得

以下URLにアクセスし、サンプル音声を以下から取得してください。

https://github.com/FairyDevicesRD/mimi.example.ruby/raw/master/audio.raw

Step2 : 音声認識サービスの実行

アクセストークンを発行したら、音声認識サービスを実行することができます。以下はHTTPサービスの利用例です。HTTPカスタムヘッダに、必要な設定を記述します。

実行例

mimi ASR powered by NICT v2を利用する場合の実行例

curl -X POST https://service.mimi.fd.ai \
-H "Content-Type: audio/x-pcm;bit=16;rate=16000;channels=1" \
-H "x-mimi-process:nict-asr" \
-H "x-mimi-input-language:ja" \
-H "x-mimi-nict-asr-options: response_format=v2;progressive=false" \
-H "Authorization: Bearer <accessToken>" \
--data-binary @/path/to/audio.raw

mimi ASR を利用する場合の実行例

curl -X POST https://service.mimi.fd.ai \
-H "Content-Type: audio/x-pcm;bit=16;rate=16000;channels=1" \
-H "x-mimi-process:asr" \
-H "Authorization: Bearer <accessToken>" \
--data-binary @/path/to/audio.raw

応答例

mimi ASR powered by NICT を利用する場合の応答例

{
    "type": "asr#nictlvcsr2",
    "session_id": "2f4e85aa-a923-4cdf-b85f-7726d2886092",
    "status": "recog-finished",
    "response": [
        {
            "result": "ちょっと遅い昼食をとるた めファミリーレストランに入ったのです。",
            "words": [
                "ちょっと",
                "遅い",
                "昼食",
                "を",
                "とる",
                "ため",
                "ファミリーレストラン",
                "に",
                "入っ",
                "た",
                "の",
                "です"
            ],
            "determined": true,
            "time": 0
        }
    ]
}

mimi ASR を利用する場合の応答例

{ "response" :
  [
    { 
     "pronunciation" : "ローニャク",
     "result" : "老若",
     "time" : [ 650, 1430 ]
    }, {
      "pronunciation" : "ナンニョ",
      "result" : "男女", 
      "time" : [ 1430, 1950 ] 
    }, {
      "pronunciation" : "ガ",
      "result" : "が", 
      "time" : [ 1950, 2100 ]
    }, {
      "pronunciation" : "ヒ", 
      "result" : "火", 
      "time" : [ 2100, 2410 ]
    }, { 
      "pronunciation" : "ヲ",
      "result" : "を", 
      "time" : [ 2410, 2520 ]
    }, {
      "pronunciation" : "カコン",
      "result" : "囲ん", 
      "time" : [ 2520, 3060 ]
    }, {
      "pronunciation" : "デ", 
      "result" : "で", 
      "time" : [ 3060, 3210 ]
    }, { 
      "pronunciation" : "ノミ",
      "result" : "のみ", 
      "time" : [ 3240, 3560 ]
    }, { 
      "pronunciation" : "テ",
      "result" : "手", 
      "time" : [ 3690, 3890 ]
    }, {
      "pronunciation" : "ヲ",
      "result" : "を", 
      "time" : [ 3890, 4020 ]
    }, {
      "pronunciation" : "ツナイ", 
      "result" : "つない",
      "time" : [ 4020, 4530 ] 
    }, {
      "pronunciation" : "デ", 
      "result" : "で",
      "time" : [ 4530, 4790 ]
    }, {
      "pronunciation" : "ウタウ", 
      "result" : "歌う", 
      "time" : [ 4790, 5180 ]
    } 
  ],
  "session_id" : "d2ba5a54-e5ac-11e9-abfd-42010a9200a5",
  "status" : "recog-finished",
  "type" : "asr#mimilvcsr"
}

音声認識の詳細な情報については mimi ASR のドキュメント および API Reference を参照ください。


What’s Next