Views
No views yet
1import torch
2from datasets import load_dataset
3from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
4from transformers.pipelines.pt_utils import KeyDataset
5
6device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
7model_id = "classla/whisper-large-v3-mici-princ"
8model = AutoModelForSpeechSeq2Seq.from_pretrained(
9 model_id,
10)
11
12model.to(device)
13processor = AutoProcessor.from_pretrained(model_id)
14
15ds = load_dataset("classla/Mici_Princ", split="test")
16pipe = pipeline(
17 "automatic-speech-recognition",
18 model=model,
19 tokenizer=processor.tokenizer,
20 feature_extractor=processor.feature_extractor,
21 max_new_tokens=128,
22 chunk_length_s=30,
23 batch_size=16,
24 return_timestamps=True,
25 device=device,
26)
27
28result = pipe(
29 KeyDataset(ds, "audio"),
30 generate_kwargs={"language": "croatian"},
31)
32
33for i in result:
34 print(i)
35
36# Output:
37# {'text': ' Šesti planet je biv deset put veći. Na njin je bivav niki stari čovik ki je pisav vele knjige.', 'chunks': [{'timestamp': (0.0, 7.18), 'text': ' Šesti planet je biv deset put veći. Na njin je bivav niki stari čovik ki je pisav vele knjige.'}]}
38# ...
39normalized_text attribute of the Mići Princ dataset. This means
that the data included capital letters and punctuation, except bullet points, newlines, and quotation marks. Special characters, present in
the dialect, but not in standard Croatian, were substituted.train split was used in training. per_device_train_batch_size=4,
gradient_accumulation_steps=4,
learning_rate=1e-5,
warmup_steps=100,
max_steps=277 * 80,
gradient_checkpointing=True,
predict_with_generate=True,
generation_max_length=225,
save_steps=277,test split of the Mići Princ dataset was used. The test split consists of two known speakers, Autor and Mići Princ, and two unknown speakers, Geograf and Dilavac. Important to note is that each speaker uses a different micro-dialect, so the test data is challenging on including two new micro-dialects.| speaker | WER vanilla | WER fine-tuned | WER reduction | CER vanilla | CER fine-tuned | CER reduction |
|---|---|---|---|---|---|---|
| all | 35.43% | 16.83% | 52.50% | 11.54% | 3.95% | 65.77% |
| Autor | 38.96% | 14.29% | 63.32% | 10.24% | 2.93% | 71.39% |
| Geograf | 20.94% | 11.57% | 44.75% | 4.99% | 2.19% | 56.11% |
| Mići Princ | 45.32% | 16.62% | 63.33% | 12.21% | 5.09% | 58.31% |
| Dilavac | 39.60% | 23.70% | 40.15% | 18.55% | 5.27% | 71.59% |