The simplest way to use Tafrigh is to provide an audio file path or URL and let the library handle all preprocessing, chunking, and transcription automatically.
import { init, transcribe } from 'tafrigh';// Initialize with your Wit.ai API keyinit({ apiKeys: ['your-wit-ai-key'] });// Transcribe a local fileconst transcript = await transcribe('path/to/audio.mp3');console.log(transcript);
The language used for transcription depends on the Wit.ai API key configuration:
import { init, transcribe } from 'tafrigh';// English transcription (use an English-configured Wit.ai key)init({ apiKeys: ['english-wit-ai-key'] });const englishTranscript = await transcribe('english-audio.mp3');// Arabic transcription (use an Arabic-configured Wit.ai key)init({ apiKeys: ['arabic-wit-ai-key'] });const arabicTranscript = await transcribe('arabic-audio.mp3');
If your Wit.ai key is configured for English and you provide Arabic audio, the transcription will not be accurate. Always match the API key language to your audio content.