Views
No views yet
1from transformers import WhisperForConditionalGeneration, WhisperProcessor
2import torch
3import librosa
4
5# Load model
6model_name = "servinosmanov/whisper-large-v3-crh"
7processor = WhisperProcessor.from_pretrained(model_name)
8model = WhisperForConditionalGeneration.from_pretrained(model_name)
9
10device = "cuda" if torch.cuda.is_available() else "cpu"
11model = model.to(device)
12model.eval()
13
14# Load and process audio
15audio, sr = librosa.load("your_audio.wav", sr=16000)
16
17input_features = processor(
18 audio,
19 sampling_rate=16000,
20 return_tensors="pt"
21).input_features.to(device)
22
23# Generate transcription (with repetition penalty recommended)
24with torch.no_grad():
25 predicted_ids = model.generate(
26 input_features,
27 max_length=225,
28 num_beams=5,
29 repetition_penalty=1.2,
30 no_repeat_ngram_size=3,
31 )
32
33transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
34print(transcription)repetition_penalty=1.2 and no_repeat_ngram_size=3 during inference to prevent repetition loops| Model | WER |
|---|---|
| whisper-medium (fine-tuned) | 26.47% |
| whisper-large-v3 (this model) | 13.67% |
| Improvement | 48.4% relative |
1@misc{whisper-large-v3-crh,
2 author = {Servin Osmanov},
3 title = {Whisper Large-v3 Fine-tuned for Crimean Tatar},
4 year = {2025},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/servinosmanov/whisper-large-v3-crh}
7}