Web Speech API
The SpeechRecognitionPhrase() constructor creates a new SpeechRecognitionPhrase object.
An array of SpeechRecognitionPhrase objects is passed into the speech recognition engine via the SpeechRecognition.phrases property for contextual biasing.
Syntax
new SpeechRecognitionPhrase(phrase)
new SpeechRecognitionPhrase(phrase, boost)
Parameters
phrase- : A string containing a word or phrase you want boosted.
boost- : A floating point number between
0.0and10.0(inclusive) that represents the weight you want to apply to thephrase. This value is roughly equivalent to the natural log of the number of times more likely the website thinks this phrase to appear than what the speech recognition model knows. Higher values make thephrasemore likely to be recognized. A value of0.0means the phrase is not boosted at all, whereas a value of10.0means the phrase is extremely likely to appear. If not specified, theboostdefaults to1.0.[!NOTE] A high value such as
9.0or10.0might make the recognition engine erroneously recognize other phrases as the specified phrase. Therefore, such values should be used rarely when constructingSpeechRecognitionPhraseobjects.
- : A floating point number between
Return value
A new SpeechRecognitionPhrase object.
Exceptions
SyntaxErrorDOMException- : The specified
boostvalue is less than0.0or greater than10.0.
- : The specified
Specifications
Browser compatibility
See also
- SpeechRecognition
- SpeechRecognition.phrases
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
