SpeechSynthesisEvent

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.

SpeechSynthesisEventウェブ音声 API のインターフェイスで、は、発話サービスで処理された SpeechSynthesisUtterance オブジェクトの現在の状態に関する情報を保持します。

Event SpeechSynthesisEvent

コンストラクター

SpeechSynthesisEvent()

新しい SpeechSynthesisEvent を作成します。

インスタンスプロパティ

以下に挙げたプロパティに加え、親インターフェイスである Event のプロパティが利用可能です。

SpeechSynthesisEvent.charIndex 読取専用

イベントが発生したときに発話されていた SpeechSynthesisUtterance.text 内の文字のインデックス位置を返します。

SpeechSynthesisEvent.charLength 読取専用

発話エンジンが対応している場合、 charIndex 位置の後に発話できる残りの文字数を返します。発話エンジンが情報を提供できない場合は 0 を返します。

SpeechSynthesisEvent.elapsedTime 読取専用

イベントが発生した時点の SpeechSynthesisUtterance.text が話し始めてからの経過時間(秒)を返します。

SpeechSynthesisEvent.name 読取専用

SpeechSynthesisUtterance.text が発話される際に発生する特定の種類のイベントに関連する名前を返します。 mark イベントの場合は到達した SSML マーカーの名前、 boundary イベントの場合は到達した境界の種類です。

SpeechSynthesisEvent.utterance 読取専用

イベントが発生した SpeechSynthesisUtterance インスタンスを返します。

インスタンスメソッド

以下に挙げたメソッドに加え、親インターフェイスである Event のメソッドが利用可能です。

js
utterThis.onpause = (event) => {
  const char = event.utterance.text.charAt(event.charIndex);
  console.log(
    `Speech paused at character ${event.charIndex} of "${event.utterance.text}", which is "${char}".`,
  );
};

utterThis.onboundary = (event) => {
  console.log(
    `${event.name} boundary reached after ${event.elapsedTime} seconds.`,
  );
};

仕様書

Specification
Web Speech API
# speechsynthesisevent

ブラウザーの互換性

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
SpeechSynthesisEvent
SpeechSynthesisEvent() constructor
charIndex
charLength
elapsedTime
elapsedTime in milliseconds
DeprecatedNon-standard
name
utterance

Legend

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

Full support
Full support
Partial support
Partial support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.

関連情報