0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【備忘録】ブラウザで音声認識する

Last updated at Posted at 2020-06-04

ブラウザに内蔵のAPIで音声認識する場合。
パラメータで認識中の途中結果を取得したり、連続で認識するといった変更はあるけど、とりあえず日本語の設定のみ。

検証環境

  • Google Chrome バージョン: 81.0.4044.138

ソースコード

html
<button id='start'>開始</button>
javascript
const start  = document.getElementById('start');

SpeechRecognition = webkitSpeechRecognition || SpeechRecognition;

const recognition = new SpeechRecognition();
recognition.lang = 'ja-JP';

recognition.onresult = (event) => {
  console.log(event.results[0][0].transcript);
}

start.onclick = (event) => {
  recognition.start();
};
0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?