SpeechRecognitionError

Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

SpeechRecognitionError interface of the Web 语音 API represents error messages from the recognition service.

This SpeechRecognitionError interface was renamed to SpeechRecognitionErrorEvent in the Web Speech API specification.

特性

SpeechRecognitionError also inherits properties from its parent interface, Event .

SpeechRecognitionError.error 只读
Returns the type of error raised.
SpeechRecognitionError.message 只读
Returns a message describing the error in more detail.

范例

var recognition = new SpeechRecognition();
recognition.onerror = function(event) {
  console.log('Speech recognition error detected: ' + event.error);
  console.log('Additional information: ' + event.message);
}
					

浏览器兼容性

No compatibility data found. Please contribute data for "api.SpeechRecognitionError" (depth: 1) to the MDN 兼容性数据存储库 .

Firefox OS permissions

To use speech recognition in an app, you need to specify the following permissions in your manifest :

"permissions": {
  "audio-capture" : {
    "description" : "Audio capture"
  },
  "speech-recognition" : {
    "description" : "Speech recognition"
  }
}
					

You also need a privileged app, so you need to include this as well:

  "type": "privileged"
					

另请参阅