SpeechSynthesisUtterance: end イベント
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月.
end は ウェブ音声 API の SpeechSynthesisUtterance オブジェクトのイベントで、発生が終了したときに発生します。
構文
このイベント名を addEventListener() などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。
addEventListener("end", (event) => {});
onend = (event) => {};
イベント型
SpeechSynthesisEvent です。 Event を継承しています。
イベントプロパティ
以下に挙げたプロパティに加え、親インターフェイスである Event のプロパティが利用可能です。
charIndex読取専用-
イベントが発生したときに発話されていた
SpeechSynthesisUtterance.text内の文字のインデックス位置を返します。 elapsedTime読取専用-
イベントが発生した時点の
SpeechSynthesisUtterance.textが話し始めてからの経過時間(秒)を返します。 name読取専用-
SpeechSynthesisUtterance.textが発話される際に発生する特定の種類のイベントに関連する名前を返します。markイベントの場合は到達した SSML マーカーの名前、boundaryイベントの場合は到達した境界の種類です。 utterance読取専用-
イベントが発生した
SpeechSynthesisUtteranceインスタンスを返します。
例
end イベントを addEventListener メソッドで使用することができます。
utterThis.addEventListener("end", (event) => {
console.log(
`Utterance has finished being spoken after ${event.elapsedTime} seconds.`,
);
});
または onend イベントハンドラープロパティで使用することができます。
utterThis.onend = (event) => {
console.log(
`Utterance has finished being spoken after ${event.elapsedTime} seconds.`,
);
};
仕様書
| Specification |
|---|
| Web Speech API> # eventdef-speechsynthesisutterance-end> |
| Web Speech API> # dom-speechsynthesisutterance-onend> |
ブラウザーの互換性
Loading…