File size: 2,646 Bytes
a8941f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eda11f1
a8941f4
cfd8171
a8941f4
b81f9a0
a8941f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0414250
a8941f4
 
 
0414250
a8941f4
0414250
a8941f4
0414250
eda11f1
 
0414250
 
a8941f4
0414250
 
a8941f4
 
0414250
a8941f4
 
 
 
0414250
 
 
 
 
 
 
 
a8941f4
 
 
 
 
 
 
 
 
 
 
 
3ce07ee
a8941f4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
language: sr
datasets:
- juznevesti-sr
tags:
- audio
- automatic-speech-recognition
widget:
- example_title: Croatian example 1
  src: https://huggingface.co/classla/wav2vec2-xls-r-parlaspeech-hr/raw/main/1800.m4a
- example_title: Croatian example 2
  src: https://huggingface.co/classla/wav2vec2-xls-r-parlaspeech-hr/raw/main/00020578b.flac.wav
- example_title: Croatian example 3
  src: https://huggingface.co/classla/wav2vec2-xls-r-parlaspeech-hr/raw/main/00020570a.flac.wav
---

# wav2vec2-xls-r-juznevesti

This model for Serbian ASR is based on the [facebook/wav2vec2-xls-r-300m model](https://huggingface.co/facebook/wav2vec2-xls-r-300m) and was fine-tuned with 58 hours of audio and transcripts from [Južne vesti](https://www.juznevesti.com/), programme '15 minuta'.

For more info on the dataset creation see [this repo](https://github.com/clarinsi/parlaspeech/tree/main/juzne_vesti).

## Metrics

Evaluation is performed on the dev and test portions of the JuzneVesti dataset

|     |      dev |     test |
|:----|---------:|---------:|
| WER | 0.295206 | 0.290094 |
| CER | 0.140766 | 0.137642 |



## Usage in `transformers`

Tested with `transformers==4.18.0`, `torch==1.11.0`, and `SoundFile==0.10.3.post1`.

```python
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
import soundfile as sf
import torch
import os

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

# load model and tokenizer
processor = Wav2Vec2Processor.from_pretrained(
    "classla/wav2vec2-xls-r-juznevesti-sr")
model = Wav2Vec2ForCTC.from_pretrained("classla/wav2vec2-xls-r-juznevesti-sr")


# download the example wav files:
os.system("wget https://huggingface.co/classla/wav2vec2-xls-r-parlaspeech-hr/raw/main/00020570a.flac.wav")

# read the wav file 
speech, sample_rate = sf.read("00020570a.flac.wav")
input_values = processor(speech, sampling_rate=sample_rate, return_tensors="pt").input_values.to(device)

# remove the raw wav file
os.system("rm 00020570a.flac.wav")

# retrieve logits
logits = model.to(device)(input_values).logits

# take argmax and decode
predicted_ids = torch.argmax(logits, dim=-1)
transcription = processor.decode(predicted_ids[0])

transcription # 'velik broj poslovnih subjekata posluje sa minosom velik deo'
```



## Training hyperparameters

In fine-tuning, the following arguments were used:

| arg                           | value |
|-------------------------------|-------|
| `per_device_train_batch_size` | 16    |
| `gradient_accumulation_steps` | 4     |
| `num_train_epochs`            | 20    |
| `learning_rate`               | 3e-4  |
| `warmup_steps`                | 500   |