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

SpeechRecognitionErrorEvent: error property

· 52CE 我爱测

The **`error`** read-only property of the SpeechRecognitionErrorEvent interface returns the type of error raised.

Web Speech API

The error read-only property of the SpeechRecognitionErrorEvent interface returns the type of error raised.

Value

An enumerated value representing the type of error. Possible values include:

  • aborted
    • : Speech input was aborted in some manner, perhaps by some user-agent-specific behavior like a button the user can press to cancel speech input.
  • audio-capture
    • : Audio capture failed.
  • bad-grammar
    • : There was an error in the speech recognition grammar or semantic tags, or the chosen grammar format or semantic tag format was unsupported.

      [!NOTE] This error is no longer part of the Web Speech API specification; the concept of grammar has been removed from the Web Speech API. Related features remain in the specification and are still recognized by supporting browsers for backwards compatibility, but they have no effect on speech recognition services.

  • language-not-supported
    • : The user agent does not support the language specified in the lang attribute of the SpeechRecognition object. The set of supported languages is browser-dependent, and there is no way to programmatically determine from front-end code the languages a user's browser supports for speech recognition.
  • network
    • : Network communication required for completing the recognition failed.
  • no-speech
    • : No speech was detected.
  • not-allowed
    • : The user agent disallowed any speech input from occurring for reasons of security, privacy or user preference.
  • phrases-not-supported
    • : The speech recognition model does not support SpeechRecognition.phrases for contextual biasing.
  • service-not-allowed
    • : The user agent disallowed the requested speech recognition service, either because the user agent doesn't support it or because of reasons of security, privacy or user preference. In this case it would allow another more suitable speech recognition service to be used instead.

Examples

const recognition = new SpeechRecognition();

recognition.onerror = (event) => {
  console.log(`Speech recognition error detected: ${event.error}`);
  console.log(`Additional information: ${event.message}`);
};

Specifications

Browser compatibility

See also

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

资料来源与适用范围

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

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

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