Dictation
Dictation turns speech into a transcript while the user is still speaking. The SDK streams the audio and returns the transcript in two parts: the text that has been finalized, and the text that is still being processed and can still change. Use it when you want the words themselves rather than a structured note. For structured clinical output, see Consultation.
It runs on the same SDK as consultation recording, so the setup is identical: request an access token on your server, initialize the SDK in your client, and select a microphone. See Authentication, SDK installation and Recording with the SDK for those steps. If you would rather not build the recording interface yourself, the Consultation widget has a dictation flow built in.
Starting a dictation
To start a dictation, call startRecording with the templateId set to 'dictation_api'.
const consultation = await squire.startRecording({
inputLanguage: 'en',
templateId: 'dictation_api',
});Handling transcription results
Listen for the summary-ready event to receive transcription updates. The event is triggered multiple times during the dictation, providing intermediate results.
The summary object in the event payload contains the transcription data. The transcription is divided into two parts:
fixed: The portion of the transcript that has been finalized.ongoing: The portion of the transcript that is still being processed and may change.
Here’s how you can access and display the transcription:
squire.on('summary-ready', (summary) => {
const transcription = summary.data?.find((d) => d.template === 'dictation_api');
if (!transcription) return;
const transcriptionSection = transcription.sections?.find((s) => s.section_id === 'transcription');
if (!transcriptionSection) return;
const fixedText = transcriptionSection.fields.fixed?.text || '';
const ongoingText = transcriptionSection.fields.ongoing?.text || '';
// Update your UI with the fixed and ongoing text.
document.getElementById('fixed-text-output').textContent = fixedText;
document.getElementById('ongoing-text-output').textContent = ongoingText;
});When the dictation is stopped, a final summary-ready event is emitted with the complete transcription. The report_status field in the summary will be 'final'.
For more details on the structure of the summary, refer to the output documentation.
Error handling
Dictation sessions report failures the same way consultation recordings do. See Error handling for session states, retries and API errors.