Skip to main content
Follow along with the runnable example. This guide walks through the Raw SDK mic example in corti-examples — bootstrap your build from it or use it as reference.
This guide shows how to wire your own microphone controls to the Corti SDK for real-time dictation. Your application owns audio capture — the record button, device selection, level metering — and streams frames to the Transcribe API through an SDK socket. Use this approach when you already have microphone handling in your app, or need lower-level control than a prebuilt UI provides.
If you don’t need to own the microphone yourself, the Dictation Web Component handles recording device management, streaming, and the transcript UI for you. It is the recommended starting point and is used throughout the rest of these guides. Reach for the raw SDK only when you need to integrate existing mic controls or build a fully custom interface.

How it works

The SDK wraps the Transcribe WebSocket with a promise-based connect(). The flow is:
1

Construct the client

Create a CortiClient with your auth. See the raw SDK mic example in corti-examples for the setup code.
2

Connect and send configuration

Call client.transcribe.connect({ configuration }). The promise resolves only after the server returns CONFIG_ACCEPTED, so audio is never sent before the handshake completes.
3

Stream audio frames

Capture the microphone with MediaRecorder and pass each chunk’s arrayBuffer() to socket.sendAudio().
4

Handle transcripts

Listen for transcript messages and insert the text into your target field.

Prerequisites

  • The Corti SDK: npm install @corti/sdk
  • A token source that returns { accessToken, expiresIn }. See the Authentication guide for the available flows.
See the raw SDK mic example in corti-examples for client construction and socket connection — the examples below focus on the audio capture side.

Capture the microphone

Request the microphone with getUserMedia, then feed MediaRecorder output to the socket. A short timeslice (100–250 ms) keeps latency low.
JavaScript
To drive an audio-level meter, tap the same MediaStream with a Web Audio AnalyserNode — no extra permission or second capture is required.

Stop and clean up

On stop or unmount, stop the recorder and release the microphone tracks. Also close the SDK socket so the session ends cleanly.
JavaScript
Always release the MediaStream tracks and close the SDK socket. Leaving the microphone open holds the OS recording indicator and keeps the WebSocket session billing/active.

Next steps

Text Insertion

Insert transcripts into a target field with correct spacing and casing.

Dictation Web Component

Skip manual mic handling with a prebuilt, styleable dictation UI.

Example code

The complete, runnable Raw SDK mic example in corti-examples.
Please contact us for help or questions.