Whisper Fine-tuned for Jordanian Arabic
This repository provides a script to transcribe audio files using a fine-tuned version of the OpenAI Whisper Large-V2 model, specifically optimized for the Jordanian Arabic dialect.
Features
- Transcribes audio files directly into text.
- Automatically handles sample rate conversion (resampling to 16kHz).
- Batch processes all audio files in a directory.
- Outputs results into a convenient CSV format (
filename|transcription).
Prerequisites
Before running the script, ensure you have the following installed:
- Python 3.8 or higher
- PyTorch (with CUDA support recommended for faster processing)
- Torchaudio
- Transformers
- Accelerate
- TQDM
You can install the dependencies via pip:
1pip install torch torchaudio transformers accelerate tqdm
2
Model Setup
The script is configured to look for a model checkpoint at the following path:
./checkpoints
Ensure your fine-tuned model files (weights, processor, and config) are placed in that directory. If your checkpoint has a different name, update the model_id variable in the load_model() function inside transcribe.py.
Usage
1. Prepare your data
Place your audio files (e.g., .wav, .mp3) in a folder (default is wavs/).
2. Run the transcription
Execute the script using the following command:
1python transcribe.py --input_dir path/to/your/audio --output_file results.csv
2
Arguments:
--input_dir: The directory containing your audio files. (Default: wavs)
--output_file: The name of the CSV file where transcriptions will be saved. (Default: transcription.csv)
How it works
- Model Loading: The script loads the fine-tuned Whisper model using
AutoModelForSpeechSeq2Seq.
- Preprocessing: It uses
torchaudio to load files and automatically resamples them to 16,000Hz if necessary.
- Inference: The model generates text based on the audio features.
- Saving: It appends each transcription to the output file in the format
filename|text.
Credits
This implementation is based on the
OpenAI Whisper Large-V2 tutorial and documentation.
"""