SpeechRecognition() は SpeechRecognition
オブジェクトインスタンスを作成します。
構文
var myRecognition = new SpeechRecognition();
パラメータ
なし。
サンプル
このコードは、Speech color changer から引用しています。
var grammar = '#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;'
var recognition = new SpeechRecognition();
var speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
//recognition.continuous = false;
recognition.lang = 'en-US';
recognition.interimResults = false;
recognition.maxAlternatives = 1;
...
仕様
仕様 | 策定状況 | コメント |
---|---|---|
Web Speech API SpeechRecognition() の定義 |
ドラフト |
ブラウザ実装状況
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Firefox OS permissions
speech recognition を使用するには、manifest に下記の permissions 設定が必要です:
"permissions": {
"audio-capture" : {
"description" : "Audio capture"
},
"speech-recognition" : {
"description" : "Speech recognition"
}
}
特権を持ったアプリの場合は下記も設定して下さい:
"type": "privileged"