SpeechRecognition:grammars 屬性
介面的 SpeechRecognitiongrammars 屬性會返回並設定一個 SpeechGrammar 物件集合,這些物件代表當前 SpeechRecognition 所能理解的語法。
注意: 語法概念已從 Web Speech API 中移除。相關的特性仍然保留在規範中,並且仍然被支援的瀏覽器識別以保持向後相容,但它們對語音識別服務沒有影響。
值
一個 SpeechGrammarList,其中包含代表你的應用所使用的語法的 SpeechGrammar 物件。
示例
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 # dom-speechrecognition-grammars |
瀏覽器相容性
載入中…