Language Technologies, Bangor University
commited on
Commit
·
495b32e
1
Parent(s):
c8b3f0f
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,76 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- cy
|
4 |
+
- en
|
5 |
+
datasets:
|
6 |
+
- common_voice
|
7 |
+
metrics:
|
8 |
+
- wer
|
9 |
+
tags:
|
10 |
+
- automatic-speech-recognition
|
11 |
+
- speech
|
12 |
license: apache-2.0
|
13 |
+
model-index:
|
14 |
+
- name: wav2vec2-xlsr-ft-en-cy
|
15 |
+
results:
|
16 |
+
- task:
|
17 |
+
name: Speech Recognition
|
18 |
+
type: automatic-speech-recognition
|
19 |
+
dataset:
|
20 |
+
name: Common Voice cy
|
21 |
+
type: common_voice
|
22 |
+
args: cy
|
23 |
+
metrics:
|
24 |
+
- name: Test WER
|
25 |
+
type: wer
|
26 |
+
value: 17.70%
|
27 |
---
|
28 |
+
|
29 |
+
# wav2vec2-xlsr-ft-en-cy
|
30 |
+
|
31 |
+
A speech recognition acoustic model for Welsh and English, fine-tuned from [facebook/wav2vec2-large-xlsr-53](https://huggingface.co/facebook/wav2vec2-large-xlsr-53) using English/Welsh balanced data derived from version 11 of their respective Common Voice datasets (https://commonvoice.mozilla.org/cy/datasets). Custom bilingual Common Voice train/dev and test splits were built using the scripts at https://github.com/techiaith/docker-commonvoice-custom-splits-builder#introduction
|
32 |
+
|
33 |
+
Source code and scripts for training wav2vec2-xlsr-ft-en-cy can be found at [https://github.com/techiaith/docker-wav2vec2-cy](https://github.com/techiaith/docker-wav2vec2-cy/blob/main/train/fine-tune/python/run_en_cy.sh).
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
## Usage
|
38 |
+
|
39 |
+
The wav2vec2-xlsr-ft-en-cy model can be used directly as follows:
|
40 |
+
|
41 |
+
```python
|
42 |
+
import torch
|
43 |
+
import torchaudio
|
44 |
+
import librosa
|
45 |
+
|
46 |
+
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
47 |
+
|
48 |
+
processor = Wav2Vec2Processor.from_pretrained("techiaith/wav2vec2-xlsr-ft-en-cy")
|
49 |
+
model = Wav2Vec2ForCTC.from_pretrained("techiaith/wav2vec2-xlsr-ft-en-cy")
|
50 |
+
|
51 |
+
audio, rate = librosa.load(audio_file, sr=16000)
|
52 |
+
|
53 |
+
inputs = processor(audio, sampling_rate=16_000, return_tensors="pt", padding=True)
|
54 |
+
|
55 |
+
with torch.no_grad():
|
56 |
+
tlogits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
|
57 |
+
|
58 |
+
# greedy decoding
|
59 |
+
predicted_ids = torch.argmax(logits, dim=-1)
|
60 |
+
|
61 |
+
print("Prediction:", processor.batch_decode(predicted_ids))
|
62 |
+
|
63 |
+
```
|
64 |
+
|
65 |
+
## Evaluation
|
66 |
+
|
67 |
+
|
68 |
+
According to a balanced English+Welsh test set derived from Common Voice version 11, the WER of techiaith/wav2vec2-xlsr-ft-en-cy is **17.7%**
|
69 |
+
|
70 |
+
However, when evaluated with language specific test sets, the model exhibits a bias to perform better with Welsh.
|
71 |
+
|
72 |
+
| Common Voice Test Set Language | WER | CER |
|
73 |
+
| -------- | --- | --- |
|
74 |
+
| EN+CY | 17.07| 7.32 |
|
75 |
+
| EN | 27.54 | 11.6 |
|
76 |
+
| CY | 7.13 | 2.2 |
|