Automatic Speech Recognition
Transformers
Safetensors
Welsh
English
wav2vec2
speech
Inference Endpoints
File size: 2,307 Bytes
a7cee1f
495b32e
 
 
 
 
 
 
 
 
 
a7cee1f
495b32e
 
 
 
 
 
 
 
 
 
 
 
 
 
a7cee1f
495b32e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
language: 
 - cy
 - en
datasets:
- common_voice
metrics:
- wer
tags:
- automatic-speech-recognition
- speech
license: apache-2.0
model-index:
- name: wav2vec2-xlsr-ft-en-cy
  results:
  - task:
      name: Speech Recognition
      type: automatic-speech-recognition
    dataset:
      name: Common Voice cy
      type: common_voice
      args: cy
    metrics:
    - name: Test WER
      type: wer
      value: 17.70%
---

# wav2vec2-xlsr-ft-en-cy

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

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). 



## Usage

The wav2vec2-xlsr-ft-en-cy model can be used directly as follows:

```python
import torch
import torchaudio
import librosa

from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor

processor = Wav2Vec2Processor.from_pretrained("techiaith/wav2vec2-xlsr-ft-en-cy")
model = Wav2Vec2ForCTC.from_pretrained("techiaith/wav2vec2-xlsr-ft-en-cy")

audio, rate = librosa.load(audio_file, sr=16000)

inputs = processor(audio, sampling_rate=16_000, return_tensors="pt", padding=True)

with torch.no_grad():
  tlogits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits

# greedy decoding
predicted_ids = torch.argmax(logits, dim=-1)

print("Prediction:", processor.batch_decode(predicted_ids))

```

## Evaluation


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%**

However, when evaluated with language specific test sets, the model exhibits a bias to perform better with Welsh.  

| Common Voice Test Set Language | WER | CER | 
| -------- | --- | --- | 
| EN+CY | 17.07| 7.32  | 
| EN | 27.54  | 11.6  |
| CY | 7.13  | 2.2  |