SpeechSynthesisEvent
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2018年9月.
SpeechSynthesisEvent はウェブ音声 API のインターフェイスで、は、発話サービスで処理された SpeechSynthesisUtterance オブジェクトの現在の状態に関する情報を保持します。
コンストラクター
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 のメソッドが利用可能です。
例
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> |
ブラウザーの互換性
Loading…