SpeechSynthesisUtterance: boundary イベント
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
boundary は ウェブ音声 API のイベントで、発話が胡屋分の境界に達したときに発生します。
構文
このイベント名を addEventListener() などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。
js
addEventListener("boundary", (event) => {});
onboundary = (event) => {};
イベント型
SpeechSynthesisEvent です。 Event を継承しています。
イベントプロパティ
以下に挙げたプロパティに加え、親インターフェイスである Event のプロパティが利用可能です。
charIndex読取専用-
イベントが発生したときに発話されていた
SpeechSynthesisUtterance.text内の文字のインデックス位置を返します。 elapsedTime読取専用-
イベントが発生した時点の
SpeechSynthesisUtterance.textが話し始めてからの経過時間(秒)を返します。 name読取専用-
SpeechSynthesisUtterance.textが発話される際に発生する特定の種類のイベントに関連する名前を返します。markイベントの場合は到達した SSML マーカーの名前、boundaryイベントの場合は到達した境界の種類です。 utterance読取専用-
イベントが発生した
SpeechSynthesisUtteranceインスタンスを返します。
例
boundary イベントを addEventListener メソッドで使用することができます。
js
utterThis.addEventListener("boundary", (event) => {
console.log(
`${event.name} boundary reached after ${event.elapsedTime} seconds.`,
);
});
または onboundary イベントハンドラープロパティで使用することができます。
js
utterThis.onboundary = (event) => {
console.log(
`${event.name} boundary reached after ${event.elapsedTime} seconds.`,
);
};
仕様書
| Specification |
|---|
| Web Speech API> # eventdef-speechsynthesisutterance-boundary> |
| Web Speech API> # dom-speechsynthesisutterance-onboundary> |
ブラウザーの互換性
Loading…