Views
No views yet
1from transformers import WhisperProcessor, WhisperForConditionalGeneration
2import torchaudio
3import torch
4
5model_path = "scb10x/monsoon-whisper-medium-gigaspeech2"
6device = "cuda"
7filepath = 'audio.wav'
8
9processor = WhisperProcessor.from_pretrained(model_path)
10model = WhisperForConditionalGeneration.from_pretrained(
11 model_path, torch_dtype=torch.bfloat16
12)
13model.to(device)
14model.eval()
15
16model.config.forced_decoder_ids = processor.get_decoder_prompt_ids(
17 language="th", task="transcribe"
18)
19array, sr = torchaudio.load(filepath)
20input_features = (
21 processor(array, sampling_rate=sr, return_tensors="pt")
22 .to(device)
23 .to(torch.bfloat16)
24 .input_features
25)
26predicted_ids = model.generate(input_features)
27transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
28print(transcription)| Model | WER (GS2) | WER (CV17) | CER (GS2) | CER (CV17) |
|---|---|---|---|---|
| whisper-large-v3 | 37.02 | 22.63 | 24.03 | 8.49 |
| whisper-medium | 55.64 | 43.01 | 37.55 | 16.41 |
| biodatlab-whisper-th-medium-combined | 31.00 | 14.25 | 21.20 | 5.69 |
| biodatlab-whisper-th-large-v3-combined | 29.02 | 15.72 | 19.96 | 6.32 |
| monsoon-whisper-medium-gigaspeech2 | 22.74 | 20.79 | 14.15 | 6.92 |