大网数据广告活动
Web 标准与前端开发

SpeechRecognitionPhrase: SpeechRecognitionPhrase() constructor

· 52CE 我爱测

The **`SpeechRecognitionPhrase()`** constructor creates a new SpeechRecognitionPhrase object.

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.0 and 10.0 (inclusive) that represents the weight you want to apply to the phrase. 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 the phrase more likely to be recognized. A value of 0.0 means the phrase is not boosted at all, whereas a value of 10.0 means the phrase is extremely likely to appear. If not specified, the boost defaults to 1.0.

      [!NOTE] A high value such as 9.0 or 10.0 might make the recognition engine erroneously recognize other phrases as the specified phrase. Therefore, such values should be used rarely when constructing SpeechRecognitionPhrase objects.

Return value

A new SpeechRecognitionPhrase object.

Exceptions

  • SyntaxError DOMException
    • : The specified boost value is less than 0.0 or greater than 10.0.

Specifications

Browser compatibility

See also

  • SpeechRecognition
  • SpeechRecognition.phrases

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。