SpeechSynthesisEvent: SpeechSynthesisEvent() 建構函式
SpeechSynthesisEvent() 建構函式建立一個新的 SpeechSynthesisEvent 物件。
注意: Web 開發者通常不需要呼叫此建構函式,因為瀏覽器在觸發事件時會自動建立這些物件。
語法
js
new SpeechSynthesisEvent(type, options)
引數
type-
一個包含事件名稱的字串。它是區分大小寫的,瀏覽器將其設定為
start、end、error、pause、resume、mark或boundary。 options-
一個物件,除了在
Event()中定義的屬性之外,還具有以下屬性:utterance-
一個
SpeechSynthesisUtterance物件,即觸發該事件的語音請求。 charIndex可選-
在事件觸發時正在朗讀的
SpeechSynthesisUtterance.text中的字元索引位置。其預設值為0。 charLength可選-
在
charIndex位置的字元之後,剩餘需要朗讀的字元數。其預設值為0。 elapsedTime可選-
自
SpeechSynthesisUtterance.text開始朗讀以來經過的秒數,事件在該時間點被觸發。其預設值為0。 name可選-
與某些型別事件關聯的名稱:在
mark事件的情況下,是到達的 SSML 標記的名稱;在boundary事件的情況下,是到達的邊界的型別。其預設值為空字串("")。
返回值
一個新的 SpeechSynthesisEvent 物件。
規範
| 規範 |
|---|
| Web Speech API # dom-speechsynthesisevent-speechsynthesisevent |
瀏覽器相容性
載入中…