Views
No views yet
openai/whisper-small model for Automatic Speech Recognition (ASR) specifically targeting the Egyptian Arabic dialect.MAdel121/arabic-egy-cleaned dataset.ar)transformers library pipeline for automatic speech recognition. Ensure you have transformers and torch installed (pip install transformers torch).1from transformers import pipeline
2import torch
3
4# Ensure you have ffmpeg installed for audio processing
5# pip install -U ffmpeg-python # or install via system package manager
6
7device = "cuda:0" if torch.cuda.is_available() else "cpu"
8
9# Replace "your-username/whisper-small-egyptian-arabic" with the actual model ID on the Hub
10pipe = pipeline(
11 "automatic-speech-recognition",
12 model="your-username/whisper-small-egyptian-arabic", # <<< Replace this
13 device=device
14)
15
16# Load your audio file (requires ffmpeg)
17# For local files:
18audio_file = "/path/to/your/egyptian_arabic_audio.wav"
19result = pipe(audio_file, chunk_length_s=30, batch_size=8) # Adjust batch_size based on GPU memory
20
21# For datasets library audio:
22# from datasets import load_dataset
23# ds = load_dataset("MAdel121/arabic-egy-cleaned", "default", split="test") # Example
24# sample = ds[0]["audio"]
25# result = pipe(sample.copy()) # Pass a copy to avoid modifying original
26
27print(result["text"])
28
29# --- Using AutoModelForSpeechSeq2Seq ---
30from transformers import WhisperProcessor, WhisperForConditionalGeneration
31import torchaudio
32
33# Load the processor and model (replace with your model ID)
34model_id = "your-username/whisper-small-egyptian-arabic" # <<< Replace this with your dataset file on hugging face
35processor = WhisperProcessor.from_pretrained(model_id)
36model = WhisperForConditionalGeneration.from_pretrained(model_id).to(device)
37
38# Load and preprocess audio
39waveform, sample_rate = torchaudio.load(audio_file)
40if sample_rate != processor.feature_extractor.sampling_rate:
41 resampler = torchaudio.transforms.Resample(sample_rate, processor.feature_extractor.sampling_rate)
42 waveform = resampler(waveform)
43
44input_features = processor(waveform.squeeze().numpy(), sampling_rate=processor.feature_extractor.sampling_rate, return_tensors="pt").input_features.to(device)
45
46# Generate transcription
47# Set forced_decoder_ids for Arabic transcription
48forced_decoder_ids = processor.get_decoder_prompt_ids(language="ar", task="transcribe")
49predicted_ids = model.generate(input_features, forced_decoder_ids=forced_decoder_ids)
50
51transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
52print(transcription[0])pipeline or AutoModel classes. If you are using the original .ckpt file, refer to the project's main README.md and the infer_whisper_local.py script for loading instructions.MAdel121/arabic-egy-cleaned dataset available on the Hugging Face Hub. This dataset contains cleaned audio samples and corresponding transcriptions in Egyptian Arabic.speechbrain==1.0.3) with Hugging Face Transformers (transformers==4.51.3) and Accelerate (accelerate==0.25.0).openai/whisper-smallMAdel121/arabic-egy-cleanedlr=1e-5, weight_decay=0.05)improvement_threshold=0.0025, annealing_factor=0.9, patient=0)augment_prob_master=0.5, min_augmentations=1, max_augmentations=3) with the following techniques applied randomly from the pool:
length: 1600-4800 samples, count: 1-5)count: 1-3)gpu=A100-40GB)MAdel121/arabic-egy-cleaned dataset.| Metric | Value (%) |
|---|---|
| WER | 22.69 |
| CER | 16.70 |
1@article{radford2023robust,
2 title={Robust Speech Recognition via Large-Scale Weak Supervision},
3 author={Radford, Alec and Kim, Jong Wook and Xu, Tao and Brockman, Greg and McLeavey, Christine and Sutskever, Ilya},
4 journal={arXiv preprint arXiv:2212.04356},
5 year={2023}
6}
7
8@misc{adel_mohamed_2024_12860997,
9 author = {Adel Mohamed},
10 title = {MAdel121/arabic-egy-cleaned},
11 month = jun,
12 year = 2024,
13 publisher = {Zenodo},
14 doi = {10.5281/zenodo.12860997},
15 url = {https://doi.org/10.5281/zenodo.12860997}
16}
17
18@misc{speechbrain,
19 title={{SpeechBrain}: A General-Purpose Speech Toolkit},
20 author={Mirco Ravanelli and Titouan Parcollet and Peter Plantinga and Aku Rouhe and Samuele Cornell and Loren Lugosch and Cem Subakan and Nauman Dawalatabad and Abdelwahab Heba and Jianyuan Zhong and Ju-Chieh Chou and Sung-Lin Yeh and Szu-Wei Fu and Chien-Feng Liao and Elena Rastorgueva and François Grondin and William Aris and Hwidong Na and Yan Gao and Renato De Mori and Yoshua Bengio},
21 year={2021},
22 eprint={2106.04624},
23 archivePrefix={arXiv},
24 primaryClass={eess.AS},
25 note={arXiv:2106.04624}
26}ceeu3g6c)