Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. SpeechSynthesisErrorEvent
  4. error

SpeechSynthesisErrorEvent: error property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨October 2018⁩.

Theerror property of theSpeechSynthesisErrorEvent interface returns an error code indicating what has gone wrong with a speech synthesis attempt.

Value

A string containing the error reason. Possible values are:

canceled

ASpeechSynthesis.cancel method call caused theSpeechSynthesisUtterance to be removed from the queue before it hadbegun being spoken.

interrupted

ASpeechSynthesis.cancel method call caused theSpeechSynthesisUtterance to be interrupted after it had begun beingspoken and before it completed.

audio-busy

The operation couldn't be completed at this time because the user-agent couldn'taccess the audio output device (for example, the user may need to correct this byclosing another application.)

audio-hardware

The operation couldn't be completed at this time because the user-agent couldn'tidentify an audio output device (for example, the user may need to connect a speakeror configure system settings.)

network

The operation couldn't be completed at this time because some required networkcommunication failed.

synthesis-unavailable

The operation couldn't be completed at this time because no synthesis engine wasavailable (For example, the user may need to install or configure a synthesis engine.)

synthesis-failed

The operation failed because the synthesis engine raised an error.

language-unavailable

No appropriate voice was available for the language set inSpeechSynthesisUtterance.lang. You can use thewindow.speechSynthesis.getVoices() method to determine which voices and languages are supported in the user's browser.

voice-unavailable

The voice set inSpeechSynthesisUtterance.voice was not available.

text-too-long

The contents of theSpeechSynthesisUtterance.text attribute was toolong to synthesize.

invalid-argument

The content of theSpeechSynthesisUtterance.rate,SpeechSynthesisUtterance.pitch orSpeechSynthesisUtterance.volume property was not valid.

not-allowed

The operation's start was not allowed.

Examples

js
const synth = window.speechSynthesis;const inputForm = document.querySelector("form");const inputTxt = document.querySelector("input");const voiceSelect = document.querySelector("select");const voices = synth.getVoices();// …inputForm.onsubmit = (event) => {  event.preventDefault();  const utterThis = new SpeechSynthesisUtterance(inputTxt.value);  const selectedOption =    voiceSelect.selectedOptions[0].getAttribute("data-name");  for (const voice of voices) {    if (voice.name === selectedOption) {      utterThis.voice = voice;    }  }  synth.speak(utterThis);  utterThis.onerror = (event) => {    console.error(      `An error has occurred with the speech synthesis: ${event.error}`,    );  };  inputTxt.blur();};

Specifications

Specification
Web Speech API
# dom-speechsynthesiserrorevent-error

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp