SpeechRecognitionResult.isFinal

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

SpeechRecognitionResultインターフェイスの isFinal リードオンリーのプロパティは結果がファイナルかどうかの (Boolean 型) のことです。true の場合は、これは結果を返す最終の時間です。false の場合は、暫定の結果を返し、後々それは更新されます。

構文

var myIsFinal = speechRecognitionResultInstance.isFinal;

返り値

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

ブラウザー実装状況

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
isFinal

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

Firefox OS 権限

アプリで音声認識を利用する前に、下記の権限を manifest に追加する必要があります。

json
"permissions": {
  "audio-capture" : {
    "description" : "Audio capture"
  },
  "speech-recognition" : {
    "description" : "Speech recognition"
  }
}

privileged アプリ権限も必要なので、下記も追加が必要です。

json
  "type": "privileged"

関連情報