Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. SpeechRecognitionEvent
  4. SpeechRecognitionEvent()

SpeechRecognitionEvent: SpeechRecognitionEvent() constructor

Limited availability

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

TheSpeechRecognitionEvent() constructor creates a newSpeechRecognitionEvent object instance.

Syntax

js
new SpeechRecognitionEvent(type, init)

Parameters

type

A string containing the name of the event. This will beresult ornomatch, depending on the event that created the instance.

init

An initialization object that contains the following properties:

resultIndexOptional

A number representing the lowest index value result in theSpeechRecognitionResultList instance that has actually changed.

results

ASpeechRecognitionResultList object representing all the speech recognition results returned in the associated event.

Examples

You would be unlikely to construct aSpeechRecognitionEvent instance manually. Such instances are available as event objects insideresult andnomatch event handler functions.

For example:

js
recognition.addEventListener("result", (event) => {  const color = event.results[0][0].transcript;  diagnostic.textContent = `Result received: ${color}.`;  bg.style.backgroundColor = color;  console.log(`Confidence: ${event.results[0][0].confidence}`);});

Specifications

Specification
Web Speech API
# dom-speechrecognition-speechrecognition

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp