SpeechRecognitionResult.isFinal
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
io error: No such file or directory (os error 2) (/home/runner/work/yari/yari/mdn/translated-content/files/ja/web/api/speechrecognitionresult/index.md)
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
SpeechRecognitionResult
インターフェイスの isFinal
リードオンリーのプロパティは結果がファイナルかどうかの (Boolean
型) のことです。true の場合は、これは結果を返す最終の時間です。false の場合は、暫定の結果を返し、後々それは更新されます。
構文
var myIsFinal = speechRecognitionResultInstance.isFinal;
返り値
A Boolean
.
例
js
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);
};
仕様
Specification |
---|
Web Speech API # dom-speechrecognitionresult-isfinal |
ブラウザー実装状況
BCD tables only load in the browser
Firefox OS 権限
アプリで音声認識を利用する前に、下記の権限を manifest に追加する必要があります。
json
"permissions": {
"audio-capture" : {
"description" : "Audio capture"
},
"speech-recognition" : {
"description" : "Speech recognition"
}
}
privileged アプリ権限も必要なので、下記も追加が必要です。
json
"type": "privileged"