SpeechGrammarList
已棄用:此特性不再推薦。雖然某些瀏覽器可能仍然支援它,但它可能已經從相關的網路標準中刪除,可能正在刪除過程中,或者可能僅為相容性目的而保留。請避免使用它,如果可能,請更新現有程式碼;請參閱本頁底部的相容性表格以指導您的決策。請注意,此特性可能隨時停止工作。
Web Speech API 的 SpeechGrammarList 介面表示一個 SpeechGrammar 物件列表,其中包含我們希望識別服務識別的單詞或單詞模式。
語法使用 JSpeech Grammar Format (JSGF) 定義。
注意: 語法概念已從 Web Speech API 中移除。相關的特性仍然保留在規範中,並且仍然被支援的瀏覽器識別以保持向後相容,但它們對語音識別服務沒有影響。
建構函式
SpeechGrammarList()已棄用-
建立一個新的
SpeechGrammarList物件。
例項屬性
SpeechGrammarList.length只讀 已棄用-
返回
SpeechGrammarList中包含的SpeechGrammar物件的數量。
例項方法
SpeechGrammarList.item()已棄用-
標準 getter — 允許使用陣列語法從
SpeechGrammarList中檢索單個SpeechGrammar物件。 SpeechGrammarList.addFromURI()已棄用-
獲取位於特定 URI 的語法,並將其作為新的
SpeechGrammar物件新增到SpeechGrammarList中。 SpeechGrammarList.addFromString()已棄用-
將字串中的語法作為新的
SpeechGrammar物件新增到SpeechGrammarList中。
示例
js
const grammar =
"#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
const recognition = new SpeechRecognition();
const speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
規範
| 規範 |
|---|
| Web Speech API # speechgrammarlist |
瀏覽器相容性
載入中…