Each segment in the transcript contains structured timing and confidence information:
type Segment = { text: string; // The transcribed text start: number; // Start time in seconds end: number; // End time in seconds confidence?: number; // Confidence score (0-1) tokens?: Token[]; // Word-by-word breakdown};
The transcription language is determined by your Wit.ai API key configuration. If your key is configured for English and you provide Arabic audio, the transcription will be inaccurate.
Each Wit.ai API key is associated with a specific language. Make sure to:
Create separate Wit.ai apps for each language you need to support
Initialize Tafrigh with API keys that match your audio content’s language
Use different API key sets when processing multi-language content
For production deployments, you can configure API keys using environment variables instead of hardcoding them:
export WIT_AI_API_KEYS="key1 key2 key3"
Then in your code:
import { init, transcribe } from 'tafrigh';// The library will use keys from WIT_AI_API_KEYS if availableinit({ apiKeys: process.env.WIT_AI_API_KEYS?.split(' ') || [] });