UNPKG

assemblyai

Version:

The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.

49 lines (48 loc) 2.52 kB
import { BaseService } from "../base"; import { BaseServiceParams, SyncAudioInput, SyncTranscribeOptions, SyncTranscriptResponse, SyncTranscriptionConfig } from "../.."; /** * The synchronous transcription service: audio in, transcript out, * one request. * * Unlike `client.transcripts` (which submits a job to the async API and * polls for completion), `SyncTranscriber` posts the audio to the sync * API and returns the finished transcript in the HTTP response. There is no * job id or status to poll. Accepts a local file path, raw audio bytes, a * Blob, or a readable stream — but not a URL. */ export declare class SyncTranscriber extends BaseService { /** * Create a new synchronous transcription service. * @param params - The parameters to use for the service. */ constructor(params: BaseServiceParams); /** * Transcribe audio and return the finished transcript in one request. * @param audio - A local file path, raw audio bytes, a Blob, or a readable * stream. Raw PCM also requires `sample_rate` and `channels` on the config. * @param config - Options for this transcription request. * @param options - Client-side options, such as the request timeout. * @returns A promise that resolves to the finished transcript. * @throws SyncTranscriptError when the request fails. */ transcribe(audio: SyncAudioInput, config?: SyncTranscriptionConfig, options?: SyncTranscribeOptions): Promise<SyncTranscriptResponse>; /** * 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. * @param params - Optionally the model to route the probe to, so the warmed * connection lands on the same backend as the eventual transcription. * @returns 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. */ warm(params?: { model?: string; }): Promise<boolean>; }