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 イベントのイベントオブジェクトを表し、中間または最終の音声認識結果に関連するすべてのデータを保持します。
インスタンスプロパティ
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> |
ブラウザーの互換性
Loading…