transcribe( )
Provides a simple interface for transcribing audio by collecting all streaming results into a single string response.
function transcribe(params): Promise<string>;Collects all streaming results from transcribeStream() into a single string.
Parameters
| Name | Type | Required? | Description |
|---|---|---|---|
| params.modelId | string | ✓ | The identifier of the transcription model |
| params.audioChunk | string | Buffer | ✓ | Audio input as file path (string) or audio buffer |
| params.prompt | string | ✗ | Optional initial prompt to guide the transcription |
Returns
Promise<string> — The complete transcribed text.
Throws
| Error | When |
|---|---|
TRANSCRIPTION_FAILED | Transcription fails |
Example
const text = await transcribe({
modelId: "whisper-model",
audioChunk: "/path/to/audio.wav",
});
console.log(text);SUPPORTED_AUDIO_FORMATS
Use this exported constant to check which audio formats are accepted before passing a file to transcribe(). Avoids runtime errors from unsupported formats.
import { SUPPORTED_AUDIO_FORMATS } from "@qvac/sdk";
const ext = filePath.split(".").pop();
if (!SUPPORTED_AUDIO_FORMATS.includes(ext)) {
console.error(`Unsupported format: ${ext}`);
}