Downloads · 30 days
45
20% of all-time downloads
sadrasa97/whisper-large-v3-turbo-fa
whisper-large-v3-turbo-fa is a automatic speech recognition model from sadrasa97. Use it when you need speech turned into text. It is set up for transformers. The card lists the license as apache-2.0.
This repository contains a Persian (Farsi) fine-tuned version of OpenAI Whisper Large V3 Turbo for automatic speech recognition (ASR).
Downloads · 30 days
45
20% of all-time downloads
All-time downloads
225
Public
Parameters
809M
1.6 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors1.6 GB · 100%
From the Hugging Face model README
This repository contains a Persian (Farsi) fine-tuned version of OpenAI Whisper Large V3 Turbo for automatic speech recognition (ASR).
sadrasa97/whisper-large-v3-turbo-faopenai/whisper-large-v3-turbofapip install -U torch transformers accelerate librosa soundfile
## Quick Start
The recommended way to use the model is with the Hugging Face `pipeline` API.
```python
import torch
from transformers import (
AutoModelForSpeechSeq2Seq,
AutoProcessor,
pipeline,
)
model_id = "sadrasa97/whisper-large-v3-turbo-fa"
device = "cuda:0" if torch.cuda.is_available() else "cpu"
torch_dtype = (
torch.float16
if torch.cuda.is_available()
else torch.float32
)
model = AutoModelForSpeechSeq2Seq.from_pretrained(
model_id,
torch_dtype=torch_dtype,
low_cpu_mem_usage=True,
)
model.to(device)
processor = AutoProcessor.from_pretrained(
model_id
)
pipe = pipeline(
"automatic-speech-recognition",
model=model,
tokenizer=processor.tokenizer,
feature_extractor=processor.feature_extractor,
torch_dtype=torch_dtype,
device=0 if torch.cuda.is_available() else -1,
)
result = pipe(
"audio.wav",
generate_kwargs={
"language": "fa",
"task": "transcribe",
},
)
print(result["text"])
For NVIDIA CUDA GPUs, FP16 inference can be used to reduce memory consumption and improve inference performance.
import torch
from transformers import (
AutoModelForSpeechSeq2Seq,
AutoProcessor,
pipeline,
)
model_id = "sadrasa97/whisper-large-v3-turbo-fa"
model = AutoModelForSpeechSeq2Seq.from_pretrained(
model_id,
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
)
model.to("cuda")
processor = AutoProcessor.from_pretrained(
model_id
)
pipe = pipeline(
"automatic-speech-recognition",
model=model,
tokenizer=processor.tokenizer,
feature_extractor=processor.feature_extractor,
torch_dtype=torch.float16,
device=0,
)
result = pipe(
"audio.wav",
generate_kwargs={
"language": "fa",
"task": "transcribe",
},
)
print(result["text"])
The model can also be used on CPU.
import torch
from transformers import (
AutoModelForSpeechSeq2Seq,
AutoProcessor,
pipeline,
)
model_id = "sadrasa97/whisper-large-v3-turbo-fa"
model = AutoModelForSpeechSeq2Seq.from_pretrained(
model_id,
torch_dtype=torch.float32,
low_cpu_mem_usage=True,
)
processor = AutoProcessor.from_pretrained(
model_id
)
pipe = pipeline(
"automatic-speech-recognition",
model=model,
tokenizer=processor.tokenizer,
feature_extractor=processor.feature_extractor,
torch_dtype=torch.float32,
device=-1,
)
result = pipe(
"audio.wav",
generate_kwargs={
"language": "fa",
"task": "transcribe",
},
)
print(result["text"])
For applications requiring lower-level control over preprocessing and generation, the model can be loaded directly.
import torch
import librosa
from transformers import (
AutoModelForSpeechSeq2Seq,
AutoProcessor,
)
model_id = "sadrasa97/whisper-large-v3-turbo-fa"
device = "cuda" if torch.cuda.is_available() else "cpu"
torch_dtype = (
torch.float16
if device == "cuda"
else torch.float32
)
model = AutoModelForSpeechSeq2Seq.from_pretrained(
model_id,
torch_dtype=torch_dtype,
low_cpu_mem_usage=True,
)
model.to(device)
model.eval()
processor = AutoProcessor.from_pretrained(
model_id
)
audio, sample_rate = librosa.load(
"audio.wav",
sr=16000,
)
inputs = processor(
audio,
sampling_rate=sample_rate,
return_tensors="pt",
)
input_features = inputs.input_features.to(device)
with torch.inference_mode():
predicted_ids = model.generate(
input_features,
language="fa",
task="transcribe",
)
transcription = processor.batch_decode(
predicted_ids,
skip_special_tokens=True,
)
print(transcription[0])
For Persian speech recognition, explicitly specify the language as Persian:
generate_kwargs = {
"language": "fa",
"task": "transcribe",
}
The task should be set to transcribe when the goal is to produce text in the original spoken language.
For example:
result = pipe(
"persian_audio.wav",
generate_kwargs={
"language": "fa",
"task": "transcribe",
},
)
print(result["text"])
Whisper operates on audio sampled at 16 kHz internally.
For best results, use:
The Hugging Face processor handles the required feature extraction.
This model can be used for:
The model is based on the Whisper Large V3 Turbo architecture.
Whisper is an encoder-decoder Transformer architecture designed for multilingual speech recognition and related speech-processing tasks.
This model has been fine-tuned for improved performance on Persian/Farsi speech.
openai/whisper-large-v3-turbo
Persian / Farsi
fa
The fine-tuning process adapts the pretrained Whisper model to Persian speech characteristics, vocabulary, pronunciation patterns, and linguistic structure.
Recommended evaluation metrics for Persian ASR include:
For Persian ASR, normalization is particularly important because Unicode variants, Arabic/Persian character differences, whitespace, punctuation, and zero-width non-joiner usage can significantly affect raw WER and CER.
When reporting performance, evaluation should preferably be performed using a held-out test set representative of the intended deployment domain.
ASR performance depends on the characteristics of the input audio and the target domain.
Potential sources of transcription errors include:
The model should be evaluated on representative production data before deployment in safety-critical or high-impact applications.
For production deployment, consider:
For real-time applications, streaming audio should be segmented into appropriate chunks and processed incrementally rather than waiting for the complete recording.
The model can be loaded directly through the standard Transformers APIs:
from transformers import (
AutoModelForSpeechSeq2Seq,
AutoProcessor,
)
model_id = "sadrasa97/whisper-large-v3-turbo-fa"
processor = AutoProcessor.from_pretrained(
model_id
)
model = AutoModelForSpeechSeq2Seq.from_pretrained(
model_id
)
This model is based on:
openai/whisper-large-v3-turbo
Original base model:
https://huggingface.co/openai/whisper-large-v3-turbo
If you use this model in academic research, please cite the original Whisper publication:
@misc{radford2022robust,
title={Robust Speech Recognition via Large-Scale Weak Supervision},
author={
Alec Radford and
Jong Wook Kim and
Tao Xu and
Greg Brockman and
Christine McLeavey and
Ilya Sutskever
},
year={2022},
eprint={2212.04356},
archivePrefix={arXiv},
primaryClass={eess.AS}
}
This model is based on openai/whisper-large-v3-turbo.
Please review the license and usage terms of the original base model, as well as the licenses and terms associated with any datasets used during fine-tuning.
Sadra Saremi
Hugging Face:
https://huggingface.co/sadrasa97