Handle dictation events

The dictation module exposes events that allow you to listen for dictation processing state changes.

To add an event listener, use the following function:

DragonCopilotSDK.dragon.recording.dictation.events.addEventListener("dictationProcessingStarted", () => {
   // Dictation processing started
});

To remove your event listener, call DragonCopilotSDK.dragon.recording.dictation.events.removeEventListener

Dictation events

Event name Detail type Description
dictationProcessingStarted null Dispatched when dictation processing has started, with no information on the specific element into which the user was dictating.
dictationProcessingFinished null Dispatched when dictation processing has finished, with no information on the specific element into which the user was dictating.
dictationProcessingStartedForElement DictationProcessingStartedForElementDetail Dispatched when dictation processing has started for a specific element.
dictationProcessingFinishedForElement DictationProcessingFinishedForElementDetail Dispatched when dictation processing has finished for a specific element.

For information on event detail types, see the API reference.

Considerations when implementing dictation events

  • The dictation events (global and text control-specific) are reliable only if recording has already been stopped; the user might start speaking again after the dictationProcessingFinished event is fired.

  • Dictation events are always fired in pairs: When recording starts (with no recognition results pending from previous recording) and when all recognition results have been processed.

Example of dictation events

Here's an example scenario to illustrate how dictation events are raised:

  • There are two controls in the form: Field 1 and Field 2. Field 1 has the speech focus when recording is started.

  • The user records three phrases without waiting for the results: this is a test, next field and this is another test. Then recording is stopped.

  • When all speech recognition processing is finished, Field 1 contains "This is a test", Field 2 contains "This is another test" and Field 2 has the speech focus.

How the events work in this scenario:

  1. Field 1 has the speech focus and the user says this is a test: dictationProcessingStarted and dictationProcessingStartedForElement(field1) events are fired.

  2. Field 1 has the speech focus and the user says next field and this is another test: Speech recognition processing is ongoing, therefore no finished events are fired.

  3. Field 2 has the speech focus, the dictationProcessingStartedForElement(field2) event is fired.

  4. "This is a test" is written in Field 1 and speech recognition processing is finished for the control, the dictationProcessingFinishedForElement(field1) event is fired.

  5. "This is another test" is written in Field 2 and speech recognition processing is finished for the control, the dictationProcessingFinishedForElement(field2) event is fired.

  6. Speech recognition processing is finished for the form, so the dictationProcessingFinished event is fired.

See also

API reference