SpeechRecognitionResult
インターフェイスの isFinal
リードオンリーのプロパティは結果がファイナルかどうかの (Boolean
型) のことです。true の場合は、これは結果を返す最終の時間です。false の場合は、暫定の結果を返し、後々それは更新されます。
構文
var myIsFinal = speechRecognitionResultInstance.isFinal;
返り値
A Boolean
.
例
recognition.onresult = function(event) {
// The SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object
// The SpeechRecognitionResultList object contains SpeechRecognitionResult objects.
// It has a getter so it can be accessed like an array
// The first [0] returns the SpeechRecognitionResult at position 0.
// Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain individual results.
// These also have getters so they can be accessed like arrays.
// The second [0] returns the SpeechRecognitionAlternative at position 0.
// We then return the transcript property of the SpeechRecognitionAlternative object
var color = event.results[0][0].transcript;
diagnostic.textContent = 'Result received: ' + color + '.';
bg.style.backgroundColor = color;
console.log(event.results[0].isFinal);
}
仕様
仕様 | 状態 | コメント |
---|---|---|
Web Speech API isFinal の定義 |
ドラフト |
ブラウザー実装状況
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 権限
アプリで音声認識を利用する前に、下記の権限を manifest に追加する必要があります。
"permissions": {
"audio-capture" : {
"description" : "Audio capture"
},
"speech-recognition" : {
"description" : "Speech recognition"
}
}
privileged アプリ権限も必要なので、下記も追加が必要です。
"type": "privileged"