The synchronous transcription service: audio in, transcript out, one connection.

Unlike client.transcripts (which submits a job to the async API and polls for completion), SyncTranscriber posts audio over a live upload to the sync API and returns the finished transcript in the HTTP response. There is no job id or status to poll. transcribe() accepts a local file path, raw audio bytes, a Blob, or a readable stream — but not a URL — and sends it as a single chunk over the same connection transcribeLive() and openLive() use for audio still being produced.

Hierarchy

  • BaseService
    • SyncTranscriber

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 live upload 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 SyncLiveSession.

    Parameters

    • config: SyncTranscriptionConfig = {}

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

    • options: SyncLiveOptions = {}

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

    Returns SyncLiveSession

    The open session.

    const session = client.sync.openLive({ sample_rate: 16000, channels: 1 });
    mic.on("data", (chunk) => session.write(chunk));
    mic.on("end", () => session.close());
    const { text } = await session.result();
  • Transcribe audio and return the finished transcript in one request.

    The audio travels as a single chunk over the same live upload transcribeLive() uses — this is the ergonomic shape for audio you already hold whole, rather than audio still being produced.

    Parameters

    • audio: SyncAudioInput

      A local file path, raw audio bytes, a Blob, or a readable stream. Raw PCM also requires sample_rate and channels on the config.

    • config: SyncTranscriptionConfig = {}

      Options for this transcription request.

    • options: SyncTranscribeOptions = {}

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

    Returns Promise<SyncTranscriptResponse>

    A promise that resolves to the finished transcript.

    Error when audio is a URL, when raw PCM is missing sample_rate or channels, or when prompt or keyterms_prompt exceeds its cap.

    SyncTranscriptError when the request fails.

  • Transcribe audio uploaded as it is produced.

    For audio that is still being produced — a live microphone, an in-progress call — this starts the request immediately and uploads chunks as they arrive, so authorization, the upload and every speech segment but the last resolve while the caller is still recording. What is left to wait for once they stop is the final segment. Audio already held whole travels the same connection as a single chunk in transcribe(), the ergonomic shape for that case.

    The saving only pays off when the audio is genuinely still being produced; audio you already hold whole belongs in transcribe(). It also needs enough audio to have segments to release early; below roughly a minute only the elided upload counts. The same 120 s audio cap applies.

    The caller must keep producing: an upload that goes silent for long enough is aborted server-side. Stop by ending the stream, not by pausing it. For sources that deliver audio through a callback rather than a stream, see openLive().

    Parameters

    • audio: SyncLiveAudioInput

      An async iterable (Node streams included), a sync iterable, or a web ReadableStream of audio chunks. Raw PCM also requires sample_rate and channels on the config. Audio you already hold whole belongs in transcribe().

    • config: SyncTranscriptionConfig = {}

      Options for this transcription request.

    • options: SyncLiveOptions = {}

      Client-side options: the request deadline, which must cover the recording, and an optional abort signal.

    Returns Promise<SyncTranscriptResponse>

    A promise that resolves to the finished transcript.

    TypeError when audio is bytes, a Blob or a path rather than a stream, or when a chunk is not bytes.

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

  • Open the connection to the sync API ahead of time.

    The sync API is a single request/response, so a transcribe() that opens its connection on demand pays the full DNS + TCP + TLS handshake on the critical path. Call warm() as soon as you know audio is coming — typically while the clip is still being recorded — so the next transcribe() reuses the already-open connection. warm() is idempotent and cheap; call it shortly before transcribe() so the pooled connection hasn't idled out.

    Parameters

    • Optionalparams: {
          model?: string;
      }

      Optionally the model to route the probe to, so the warmed connection lands on the same backend as the eventual transcription.

      • Optionalmodel?: string

    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.