The dictation service: a short spoken note in, a transcript out.

Tuned for dictation — someone speaks a note and wants it back as text, optionally cleaned up or reformatted. The audio is uploaded while it is still being spoken, from a callback with openLive() or from a stream with transcribeLive(), so the upload and every speech segment but the last are done by the time the speaker stops. Audio already held whole — bytes, a Blob, a local path — goes to transcribeLive() too and travels the same connection as a single chunk: there is one request shape here.

Unlike client.transcripts, which submits a job to the async API and polls for completion, there is no job id, no status to poll and no URL ingestion. Beyond the transcript it can run a follow-up LLM pass: set llm_instruction on the config and read final_text off the result.

Requests go to the dictation API (dictation.assemblyai.com), which the dictationBaseUrl client option overrides.

Hierarchy

  • BaseService
    • DictationTranscriber

Constructors

Methods

  • Parameters

    • input: string
    • Optionalinit: RequestInit

    Returns Promise<Response>

  • Type Parameters

    • T

    Parameters

    • input: string
    • Optionalinit: RequestInit

    Returns Promise<T>

  • Parameters

    • input: string
    • Optionalinit: RequestInit

    Returns Promise<Response>

  • Open a dictation that audio is pushed into.

    The push-style counterpart of transcribeLive(), for sources that deliver audio through a callback rather than a stream. The request starts immediately; call session.write(chunk) from the callback, then await session.result() for the transcript once the speaker stops. See DictationLiveSession.

    Parameters

    • config: DictationConfig = {}

      Options for this dictation request. Raw PCM requires sample_rate and channels.

    • options: DictationLiveOptions = {}

      Client-side options: the total request deadline, which must cover the dictation.

    Returns DictationLiveSession

    The open session.

    const session = client.dictation.openLive({ sample_rate: 16000, channels: 1 });
    mic.on("data", (chunk) => session.write(chunk));
    mic.on("end", () => session.close());
    const { final_text } = await session.result();
  • Transcribe dictated audio, uploading it as it is produced.

    Starts the request immediately and uploads chunks as they arrive, so authorization, the upload and every speech segment but the last resolve while the speaker is still talking. What is left to wait for once they stop is the final segment, and the LLM pass if one was asked for. Audio that is already complete — bytes, a Blob, a local path — is accepted as well and sent as a single chunk over the same connection.

    A producer must keep producing: an upload that goes silent for long enough is aborted server-side, so stop by ending the stream rather than pausing it. The service caps a request at 120 s of audio. For sources that deliver audio through a callback rather than a stream, see openLive().

    Parameters

    • audio: DictationAudioInput

      Audio still being produced (an async iterable, Node streams included; a sync iterable; a web ReadableStream) or audio held whole (a local file path, a data URL, raw bytes, a Blob). Raw PCM also requires sample_rate and channels on the config.

    • config: DictationConfig = {}

      Options for this dictation request.

    • options: DictationLiveOptions = {}

      Client-side options: the total request deadline and an optional abort signal.

    Returns Promise<DictationResponse>

    A promise that resolves to the finished transcript, whose final_text carries the LLM rewrite when one was asked for.

    Error when audio is a URL, or when raw PCM is missing sample_rate or channels.

    TypeError when audio is of an unsupported type, or when a produced chunk is not bytes.

    DictationError when the request fails. Auth, rate-limit, size and capacity failures can surface part-way through the upload. Anything the producer throws propagates unchanged; the connection is dropped.

    const result = await client.dictation.transcribeLive(mic, {
    sample_rate: 16000,
    channels: 1,
    llm_instruction: "Format this as a SOAP note.",
    });
    console.log(result.final_text);
  • Open the connection to the dictation API ahead of time.

    A request that opens its connection on demand pays the full DNS + TCP + TLS handshake before the first audio byte can leave — one network round trip that, for a distant client, is a noticeable share of a short dictation. Call warm() as soon as you know audio is coming — when the user reaches for the record button, say — and the next request reuses the already-open connection. It is idempotent and cheap, so calling it again to refresh the connection is fine; call it shortly before the request, since the pooled connection idles out after a few seconds.

    Returns Promise<boolean>

    A promise that resolves to true once the connection is open (any HTTP response — even a non-200 — means the socket is established), or false if the connection could not be opened.