listen Element
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Performs recognition, post-processing, and recording and configures speech recognizers.
Syntax
<listen attributes>
<grammar attributes /> // Describes the grammar source
<bind attributes /> // Associates recognition results with controls on an HTML page
<record attributes /> // Enables and configures recording of user speech
<param attributes /> // Used to pass parameters into the speech platform (optional)
</listen>
Members
The listen element consists of the following members.
Content | Description |
---|---|
grammar |
Specifies input grammar resources. |
bind |
Copies one semantic element of recognition results to an HTML page element or calls a method on that element. |
record |
Controls the recording of audio input. |
param |
Specifies a Speech Server configuration parameter. |
Attribute | Description |
---|---|
beep |
A Boolean value that specifies whether a beep is heard before recognition begins. Optional. The default is false; that is, no beep occurs before recognition. |
id |
Identifies the listen element. Optional. |
initialtimeout |
Specifies the maximum allowable time, in milliseconds, between the beginning of recognition or end of a prompt and the detection of speech. Optional. |
babbletimeout |
Specifies the maximum time, in milliseconds, for a duration of an utterance. Optional. |
maxtimeout |
Specifies the maximum allowable time, in milliseconds, between the beginning of recognition or the end of a prompt and when results are returned to the browser. Optional. |
endsilence |
Specifies the period of silence, in milliseconds, at the end of an utterance, after which the recognition attempt is considered complete. Optional. |
reject |
Specifies the recognition rejection threshold. Optional. |
xml:lang |
Specifies the language that the speech engine should use. Optional. |
mode |
Specifies which recognition mode to follow. Optional. |
Property | Description |
---|---|
recoresult |
Returns the results of recognition. Read-only. |
text |
Returns a string containing the text of the words recognized. Read-only. |
recordlocation |
Specifies the location of the recorded audio file. Used only when recording is enabled. Read-only. |
recordtype |
Specifies the MIME type of the recorded audio file. Used only when recording is enabled. Read-only. |
recordduration |
Specifies the approximate length, in milliseconds, of the recorded file. Used only when recording is enabled. Read-only. |
recordsize |
Specifies the size, in bytes, of the recorded file. Used only when recording is enabled. Read-only. |
status |
Contains the status code returned by the recognition platform. Read-only. |
Method | Description |
---|---|
Start |
Starts the recognition process. |
Stop |
Stops the recognition process and returns a result. |
Cancel |
Stops the recognition process without returning a result. |
Activate |
Activates a grammar element or one of its rules. |
Deactivate |
Deactivates a grammar element or one of its rules. |
Event | Description |
---|---|
onreco |
Occurs when the recognizer has a recognition result available for the browser. |
onsilence |
Occurs when no speech is detected by the recognition platform before the duration of time specified in the initialtimeout attribute on the recognition. |
onspeechdetected |
Occurs when the recognition engine detects speech. |
onnoreco |
Occurs when the recognition engine is unable to return valid recognition results. |
onerror |
Occurs when the speech recognition platform is unable to process a recognition request. |
Example | Description |
---|---|
listen |
A simple example using a recognition. |
Remarks
The listen element specifies possible speech inputs and provides control of speech recognition processes and results. Only one listen element can be active at a time.
The main elements of the listen element are grammar, which directs user speech to a particular recognition grammar, and bind, which places text from recognition results into a particular HTML input control. The listen element also configures speech recognition and sets recognition options using the param element.
The listen element can perform recognition-only, recognition and recording, or recording-only.
To permit the activation of multiple grammars in parallel, multiple listen elements can be active simultaneously.
A Web page can have more than one listen element, and each listen element can be used more than once. However, methods and event handlers cannot be added or changed after their declaration. Consequently, if the developer intends to have different behaviors for different items on the same page, separate listen elements must be declared. For example, a developer can declare a listen element without an onsilence event handler. If a subsequent item needs to process an onsilence event, the user must use a second listen element with the event handler defined. The onsilence event cannot be added dynamically to a page after it is rendered.