SpeechSynthesisErrorEvent

Baseline Widely available *

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

* Some parts of this feature may have varying levels of support.

SpeechSynthesisErrorEventウェブ音声 API のインターフェイスで、発話サービスの SpeechSynthesisUtterance オブジェクトの処理中に発生したエラーに関する情報を保持します。

Event SpeechSynthesisEvent SpeechSynthesisErrorEvent

コンストラクター

SpeechSynthesisErrorEvent()

新しい SpeechSynthesisErrorEvent イベントを生成します。

インスタンスプロパティ

SpeechSynthesisErrorEventSpeechSynthesisEvent インターフェイスから派生しており、親インターフェイスである Event からプロパティを継承しています。

SpeechSynthesisErrorEvent.error 読取専用

音声合成に失敗したことを示すエラーコードを返します。

インスタンスメソッド

SpeechSynthesisErrorEventSpeechSynthesisEvent インターフェイスから派生しており、親インターフェイスである Event からメソッドを継承しています。

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 (let i = 0; i < voices.length; i++) {
    if (voices[i].name === selectedOption) {
      utterThis.voice = voices[i];
    }
  }

  synth.speak(utterThis);

  utterThis.onerror = (event) => {
    console.log(
      `An error has occurred with the speech synthesis: ${event.error}`,
    );
  };

  inputTxt.blur();
};

仕様書

Specification
Web Speech API
# speechsynthesiserrorevent

ブラウザーの互換性

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
SpeechSynthesisErrorEvent
SpeechSynthesisErrorEvent() constructor
error

Legend

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

Full support
Full support
No support
No support
See implementation notes.

関連情報