Record audio

Dragon Copilot SDK for JavaScript starts and stops recording in the following ways:

  • Programmatically: Your integration calls startRecording, stopRecording or toggleRecording.

  • Microphone button: The user presses the record button on a Nuance PowerMic or Philips SpeechMike.

Control recording programmatically

Use the recording APIs to build your custom recording UI. For example:

  • A record button can use DragonCopilotSDK.dragon.recording.toggleRecording to start and stop ambient recording or dictation.

  • Use the recordingStarted and recordingStopped events to update the recording state shown to the user.

  • Use the recordingVolumeChanged event to represent the volume of speech on a volume meter.

Prerequisites

Start and stop recording

The following APIs are asynchronous and accept a recordingMode property, which you can set to "dictation" or "ambient":

  • To start recording, call DragonCopilotSDK.dragon.recording.startRecording.

  • To stop recording, call DragonCopilotSDK.dragon.recording.stopRecording.

  • To toggle recording, call DragonCopilotSDK.dragon.recording.toggleRecording.

For more information on ambient recording, see: Start ambient recording.

Important

Don't assume that calling DragonCopilotSDK.dragon.recording.toggleRecording/startRecording/stopRecording immediately starts and stops recording. Use the recordingStarted and recordingStopped events to update the recording state shown to the user and keep the UI state aligned with the SDK's recording state. Allowing the UI state to become misaligned with the recording state can make users think that recording has stopped when it's still on, and vice versa.

Enable and disable ambient recording

The following APIs are synchronous and only affect ambient recording:

  • To disable ambient recording, call DragonCopilotSDK.dragon.recording.disableRecording with recordingMode: "ambient".

  • To enable ambient recording, call DragonCopilotSDK.dragon.recording.enableRecording with recordingMode: "ambient".

Events

Use DragonCopilotSDK.dragon.recording.events.addEventListener to add event listeners for recording events.

Event Description
recordingStarted Recording has started.
recordingStopped Recording has stopped.
recordingVolumeChanged The volume of speech has changed.

See also

API reference