SpeechRecognitionEvent

Limited availability

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

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

SpeechRecognitionEventウェブ音声 API のインターフェイスで、 result および nomatch イベントのイベントオブジェクトを表し、中間または最終の音声認識結果に関連するすべてのデータを保持します。

Event SpeechRecognitionEvent

インスタンスプロパティ

SpeechRecognitionEvent は親インターフェイスである Event からプロパティを継承しています。

SpeechRecognitionEvent.emma 読取専用 非推奨; 非標準

結果の EMMA (Extensible MultiModal Annotation markup language) - XML - 表現を返します。

SpeechRecognitionEvent.interpretation 読取専用 非推奨; 非標準

ユーザーが言ったことの意味づけを返します。

SpeechRecognitionEvent.resultIndex 読取専用

実際に変更された SpeechRecognitionResultList 「配列」の中で最もインデックス値の小さい結果を返します。

SpeechRecognitionEvent.results 読取専用

現在のセッションのすべての音声認識結果を表す SpeechRecognitionResultList オブジェクトを返します。

このコードは Speech color changer の例から取得したものです。

js
recognition.onresult = (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
  const color = event.results[0][0].transcript;
  diagnostic.textContent = `Result received: ${color}.`;
  bg.style.backgroundColor = color;
};

仕様書

Specification
Web Speech API
# speechreco-event

ブラウザーの互換性

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
SpeechRecognitionEvent
SpeechRecognitionEvent() constructor
Experimental
emma
DeprecatedNon-standard
interpretation
DeprecatedNon-standard
resultIndex
results

Legend

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

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
Requires a vendor prefix or different name for use.

関連情報