1
---
2
language: ca
3
datasets:
4
- common_voice 
5
- parlament_parla
6
metrics:
7
- wer
8
tags:
9
- audio
10
- automatic-speech-recognition
11
- speech
12
- speech-to-text
13
license: apache-2.0
14
model-index:
15
- name: Catalan VoxPopuli Wav2Vec2 Large
16
  results:
17
  - task: 
18
      name: Speech Recognition
19
      type: automatic-speech-recognition
20
    datasets:
21
      - name: Common Voice ca
22
        type: common_voice
23
        args: ca
24
      - name: ParlamentParla
25
        url: https://www.openslr.org/59/
26
    metrics:
27
       - name: Test WER
28
         type: wer
29
         value: 5.98
30
       - name: Google Crowsourced Corpus WER
31
         type: wer
32
         value: 12.14
33
       - name: Audiobook “La llegenda de Sant Jordi” WER
34
         type: wer
35
         value: 12.02
36
---
37
38
# Wav2Vec2-Large-100k-VoxPopuli-Català
39
40
Fine-tuned [facebook/wav2vec2-large-100k-voxpopuli](https://huggingface.co/facebook/wav2vec2-large-100k-voxpopuli) on Catalan language using the [Common Voice](https://huggingface.co/datasets/common_voice) and [ParlamentParla](https://www.openslr.org/59/) datasets.
41
42
**Attention:** The split train/dev/test used does not fully map with the CommonVoice 6.1 dataset. A custom split was used combining both the CommonVoice and ParlamentParla dataset and can be found [here](https://github.com/ccoreilly/wav2vec2-catala). Evaluating on the CV test dataset will produce a biased WER as 1144 audio files of that dataset were used in training/evaluation of this model.
43
WER was calculated using this [test.csv](https://github.com/ccoreilly/wav2vec2-catala/blob/master/test-filtered.csv) which was not seen by the model during training/evaluation.
44
45
You can find training and evaluation scripts in the github repository [ccoreilly/wav2vec2-catala](https://github.com/ccoreilly/wav2vec2-catala)
46
47
When using this model, make sure that your speech input is sampled at 16kHz.
48
49
## Results
50
51
Word error rate was evaluated on the following datasets unseen by the model:
52
53
| Dataset | WER |
54
| ------- | --- |
55
| [Test split CV+ParlamentParla]((https://github.com/ccoreilly/wav2vec2-catala/blob/master/test-filtered.csv)) | 5.98% |
56
| [Google Crowsourced Corpus](https://www.openslr.org/69/) | 12.14% |
57
| Audiobook “La llegenda de Sant Jordi” | 12.02% | 
58
59
60
## Usage
61
62
The model can be used directly (without a language model) as follows:
63
64
```python
65
import torch
66
import torchaudio
67
from datasets import load_dataset
68
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
69
70
test_dataset = load_dataset("common_voice", "ca", split="test[:2%]")
71
72
processor = Wav2Vec2Processor.from_pretrained("ccoreilly/wav2vec2-large-100k-voxpopuli-catala") 
73
model = Wav2Vec2ForCTC.from_pretrained("ccoreilly/wav2vec2-large-100k-voxpopuli-catala")
74
75
resampler = torchaudio.transforms.Resample(48_000, 16_000)
76
77
# Preprocessing the datasets.
78
# We need to read the audio files as arrays
79
def speech_file_to_array_fn(batch):
80
	speech_array, sampling_rate = torchaudio.load(batch["path"])
81
	batch["speech"] = resampler(speech_array).squeeze().numpy()
82
	return batch
83
84
test_dataset = test_dataset.map(speech_file_to_array_fn)
85
inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
86
87
with torch.no_grad():
88
	logits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
89
90
predicted_ids = torch.argmax(logits, dim=-1)
91
92
print("Prediction:", processor.batch_decode(predicted_ids))
93
print("Reference:", test_dataset["sentence"][:2])
94
```