Views
No views yet
| MODEL | Contact Certer Set ( WER ) | Insurance Set ( WER ) |
|---|---|---|
| biodatlab/whisper-th-large-v3-combined | 0.53 | 0.33 |
| Thai Cloud STT Service | 0.47 | 0.29 |
| amity-whisper-large-stt-th-lora-v1 | 0.41 | 0.21 |
| amity-whisper-medium-stt-th-lora-v1 | 0.41 | 0.25 |
transformers as follows:1import torch
2from transformers import pipeline, AutoModelForSpeechSeq2Seq, AutoProcessor
3from peft import PeftModel
4
5BASE_MODEL = "biodatlab/whisper-th-large-v3-combined"
6LORA_MODEL = "amityco/amity-whisper-medium-stt-th-lora-v1"
7LANG = "th"
8
9device = 0 if torch.cuda.is_available() else "cpu"
10
11# 1. Load the base Whisper model
12base_model = AutoModelForSpeechSeq2Seq.from_pretrained(
13 BASE_MODEL,
14 torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
15 low_cpu_mem_usage=True,
16 device_map="auto"
17)
18
19# 2. Load and merge the LoRA weights
20model = PeftModel.from_pretrained(base_model, LORA_MODEL)
21model = model.merge_and_unload()
22
23# 3. Load processor/tokenizer
24processor = AutoProcessor.from_pretrained(BASE_MODEL)
25
26# 4. Force Thai transcription
27model.config.forced_decoder_ids = processor.tokenizer.get_decoder_prompt_ids(
28 language=LANG,
29 task="transcribe"
30)
31
32# 5. Create pipeline
33pipe = pipeline(
34 task="automatic-speech-recognition",
35 model=model,
36 tokenizer=processor.tokenizer,
37 feature_extractor=processor.feature_extractor,
38 chunk_length_s=30,
39 device=device,
40)
41
42# 6. Run transcription
43result = pipe("audio.mp3")["text"]
44print(result)
45