Views
No views yet
openai/whisper-small for Khmer automatic speech recognition. The model was trained with the utilities in whisper and is intended for transcription workloads that prioritize Khmer text normalization, including numerals, currency, and date expressions.| Attribute | Value |
|---|---|
| Base model | openai/whisper-small |
| Language | Khmer (km-KH) |
| Task | Automatic Speech Recognition (speech-to-text) |
| Sample rate | 16 kHz audio, automatically resampled |
| Input length | Up to 30 s clips (truncated during batching) |
| Finetuning data | asr_mixed_dataset.txt (internal manifests, normalized through dataset_builder.segment_text) |
| Epochs | 10 |
| Batch size | 2 (gradient accumulation 1) |
| Optimizer | AdamW (managed by Seq2SeqTrainer) |
| Learning rate | 1e-6 with cosine scheduler & 1k warmup steps |
| Normalization | Khmer-specific regex and rule-based normalization (khmerspeech, khmercut) |
| Dataset | Training with Mixed Khmer & English audio with 199K samples (225 hours), train all khmer public dataset + humaned label dataset |
| Training Time | Training with Mixed precision with RTX-5090 VRAM 32GB for 1 days |
Limitations: performance has been validated only on internal validation/test splits. Long-form audio, accents outside the training distribution, or noisy backgrounds may degrade accuracy.
1import torch
2import torchaudio
3from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
4
5
6AUDIO_PATH = "audio_path.wav"
7
8
9device = "cuda:0" if torch.cuda.is_available() else "cpu"
10torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
11model_id = "metythorn/whisper-small"
12model = AutoModelForSpeechSeq2Seq.from_pretrained(
13 model_id,
14 torch_dtype=torch_dtype,
15 low_cpu_mem_usage=True,
16 use_safetensors=True,
17)
18model.to(device)
19processor = AutoProcessor.from_pretrained(model_id)
20
21pipe = pipeline(
22 task="automatic-speech-recognition",
23 model=model,
24 tokenizer=processor.tokenizer,
25 feature_extractor=processor.feature_extractor,
26 torch_dtype=torch_dtype,
27 device=device,
28)
29
30speech_waveform, sr = torchaudio.load(AUDIO_PATH)
31
32# Whisper expects 16kHz mono
33if sr != 16000:
34 speech_waveform = torchaudio.functional.resample(
35 speech_waveform,
36 orig_freq=sr,
37 new_freq=16000
38 )
39speech_waveform = speech_waveform.squeeze().numpy()
40result = pipe(speech_waveform)
41
42print("Transcription:", result["text"])
43