Batch Transcription
client.asr.transcribe() sends an audio file and returns the complete transcript once processing is done. Best for pre-recorded files where you don't need real-time output.
Signature
client.asr.transcribe(
file: FileInput,
options?: TranscribeOptions,
requestOptions?: RequestOptions
): Promise<TranscriptionResult>
Parameters
file — FileInput
The audio to transcribe. Accepts any of:
| Type | Example |
|---|---|
Buffer | readFileSync('./audio.wav') |
Uint8Array | Raw byte array |
ArrayBuffer | From fetch response |
Blob | Browser File API |
File | <input type="file"> |
ReadableStream | Node.js / Web stream |
options — TranscribeOptions
| Property | Type | Default | Description |
|---|---|---|---|
language | Language | auto-detect | ISO code ("en") or full name ("English") |
includeScoring | boolean | false | Include per-segment quality score. Requires Professional plan. |
requestOptions — RequestOptions
| Property | Type | Default | Description |
|---|---|---|---|
timeout | number | 300000 | Request timeout in ms (5 min default) |
maxRetries | number | 2 | Override retry count for this request |
signal | AbortSignal | — | Cancellation signal |
Response — TranscriptionResult
{
jobId: string;
status: 'completed';
transcriptionText: string;
detectedLanguage: string | undefined;
qualityScore: number | undefined; // 0–5 MOS score (if includeScoring: true)
audioMetadata: {
durationSeconds: number;
sampleRate: number | undefined;
channels: number | undefined;
format: string | undefined;
bitrate: number | undefined;
} | undefined;
processingTimeMs: number | undefined;
inputUrl: string | undefined; // Presigned URL to the original file (24h TTL)
inputUrlExpiresAt: string | undefined;
inputFileSize: number | undefined;
createdAt: string;
completedAt: string | undefined;
}
Examples
Basic transcription
import { readFileSync } from 'fs';
import { Decrackle } from '@decrackle/sdk';
const client = new Decrackle({ apiKey: process.env.DECRACKLE_API_KEY });
const audio = readFileSync('./interview.wav');
const result = await client.asr.transcribe(audio, { language: 'en' });
console.log(result.transcriptionText);
console.log('Duration:', result.audioMetadata?.durationSeconds, 's');
With quality scoring
const result = await client.asr.transcribe(audio, {
language: 'en',
includeScoring: true,
});
console.log(`Transcript: ${result.transcriptionText}`);
console.log(`Quality score: ${result.qualityScore}/5`);
From a URL (fetch first)
const response = await fetch('https://example.com/audio.mp3');
const buffer = Buffer.from(await response.arrayBuffer());
const result = await client.asr.transcribe(buffer);
console.log(result.transcriptionText);
With cancellation
const controller = new AbortController();
setTimeout(() => controller.abort(), 60_000); // cancel after 60s
const result = await client.asr.transcribe(audio, {}, { signal: controller.signal });
Errors
| Error class | When |
|---|---|
DecrackleValidationError | Invalid format, language code, or file too large |
DecracklePermissionError | includeScoring requires Professional plan |
DecrackleServiceUnavailableError | ASR model temporarily unavailable |
DecrackleTimeoutError | Request exceeded the timeout |