Skip to main content
Tafrigh exports several constants that define limits and boundaries for audio processing. These constants are useful when you need to reference the maximum or minimum values supported by the library.

Available constants

MAX_CHUNK_DURATION
number
Maximum chunk duration in seconds (300 seconds / 5 minutes). This is the maximum duration supported by Wit.ai’s API.
export const MAX_CHUNK_DURATION = 60 * 5; // 300 seconds
MIN_CHUNK_DURATION
number
Minimum chunk duration in seconds (4 seconds). Chunks shorter than this are filtered out during splitting.
export const MIN_CHUNK_DURATION = 4; // 4 seconds
MIN_CONCURRENCY
number
Minimum concurrency level (1). This is the minimum number of concurrent transcription operations.
export const MIN_CONCURRENCY = 1;

Usage

Import these constants when you need to reference the limits:
import { transcribe, MAX_CHUNK_DURATION, MIN_CHUNK_DURATION } from 'tafrigh';

// Use maximum chunk duration
const result = await transcribe('audio.mp3', {
  splitOptions: {
    chunkDuration: MAX_CHUNK_DURATION, // 300 seconds
  }
});

// Validate custom chunk duration
const customDuration = 120;
if (customDuration < MIN_CHUNK_DURATION) {
  console.warn(`Chunk duration too short (minimum: ${MIN_CHUNK_DURATION}s)`);
}

When to use these constants

Maximum processing time

Use MAX_CHUNK_DURATION when you want to process the largest chunks possible to minimize API calls and maximize parallel processing efficiency.

Validation

Use MIN_CHUNK_DURATION to validate user-provided chunk durations and ensure they meet the minimum requirement.

Concurrency limits

Use MIN_CONCURRENCY as a reference when implementing custom concurrency logic.

Split options

Configure audio splitting behavior

Concurrency guide

Learn about parallel processing

Advanced configuration

Optimize chunk duration for your use case

transcribe function

Main transcription function

Build docs developers (and LLMs) love