Update README.md
Browse files
README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2 |
language: as
|
3 |
datasets:
|
4 |
- common_voice
|
5 |
-
metrics:
|
6 |
-
- wer
|
7 |
tags:
|
8 |
- audio
|
9 |
- automatic-speech-recognition
|
@@ -25,11 +23,16 @@ model-index:
|
|
25 |
type: wer
|
26 |
value: 74.25
|
27 |
---
|
|
|
28 |
# Wav2Vec2-Large-XLSR-53-Assamese
|
|
|
29 |
Fine-tuned [facebook/wav2vec2-large-xlsr-53](https://huggingface.co/facebook/wav2vec2-large-xlsr-53) in Assamese using the [Common Voice](https://huggingface.co/datasets/common_voice)
|
30 |
When using this model, make sure that your speech input is sampled at 16kHz.
|
|
|
31 |
## Usage
|
|
|
32 |
The model can be used directly (without a language model) as follows:
|
|
|
33 |
```python
|
34 |
import torch
|
35 |
import torchaudio
|
@@ -39,8 +42,10 @@ test_dataset = load_dataset("common_voice", "as", split="test[:2%]").
|
|
39 |
processor = Wav2Vec2Processor.from_pretrained("manandey/wav2vec2-large-xlsr-assamese")
|
40 |
model = Wav2Vec2ForCTC.from_pretrained("manandey/wav2vec2-large-xlsr-assamese")
|
41 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
|
|
42 |
# Preprocessing the datasets.
|
43 |
# We need to read the aduio files as arrays
|
|
|
44 |
def speech_file_to_array_fn(batch):
|
45 |
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
46 |
batch["speech"] = resampler(speech_array).squeeze().numpy()
|
@@ -53,8 +58,11 @@ predicted_ids = torch.argmax(logits, dim=-1)
|
|
53 |
print("Prediction:", processor.batch_decode(predicted_ids))
|
54 |
print("Reference:", test_dataset["sentence"][:2])
|
55 |
```
|
|
|
56 |
## Evaluation
|
|
|
57 |
The model can be evaluated as follows on the {language} test data of Common Voice.
|
|
|
58 |
```python
|
59 |
import torch
|
60 |
import torchaudio
|
@@ -66,10 +74,12 @@ wer = load_metric("wer")
|
|
66 |
processor = Wav2Vec2Processor.from_pretrained("manandey/wav2vec2-large-xlsr-assamese")
|
67 |
model = Wav2Vec2ForCTC.from_pretrained("manandey/wav2vec2-large-xlsr-assamese")
|
68 |
model.to("cuda")
|
69 |
-
chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"
|
70 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
|
|
71 |
# Preprocessing the datasets.
|
72 |
# We need to read the aduio files as arrays
|
|
|
73 |
def speech_file_to_array_fn(batch):
|
74 |
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
75 |
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
@@ -88,6 +98,8 @@ def evaluate(batch):
|
|
88 |
result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
89 |
print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
|
90 |
```
|
|
|
91 |
**Test Result**: 74.25%
|
|
|
92 |
## Training
|
93 |
The Common Voice `train`, `validation` datasets were used for training.
|
|
|
2 |
language: as
|
3 |
datasets:
|
4 |
- common_voice
|
|
|
|
|
5 |
tags:
|
6 |
- audio
|
7 |
- automatic-speech-recognition
|
|
|
23 |
type: wer
|
24 |
value: 74.25
|
25 |
---
|
26 |
+
|
27 |
# Wav2Vec2-Large-XLSR-53-Assamese
|
28 |
+
|
29 |
Fine-tuned [facebook/wav2vec2-large-xlsr-53](https://huggingface.co/facebook/wav2vec2-large-xlsr-53) in Assamese using the [Common Voice](https://huggingface.co/datasets/common_voice)
|
30 |
When using this model, make sure that your speech input is sampled at 16kHz.
|
31 |
+
|
32 |
## Usage
|
33 |
+
|
34 |
The model can be used directly (without a language model) as follows:
|
35 |
+
|
36 |
```python
|
37 |
import torch
|
38 |
import torchaudio
|
|
|
42 |
processor = Wav2Vec2Processor.from_pretrained("manandey/wav2vec2-large-xlsr-assamese")
|
43 |
model = Wav2Vec2ForCTC.from_pretrained("manandey/wav2vec2-large-xlsr-assamese")
|
44 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
45 |
+
|
46 |
# Preprocessing the datasets.
|
47 |
# We need to read the aduio files as arrays
|
48 |
+
|
49 |
def speech_file_to_array_fn(batch):
|
50 |
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
51 |
batch["speech"] = resampler(speech_array).squeeze().numpy()
|
|
|
58 |
print("Prediction:", processor.batch_decode(predicted_ids))
|
59 |
print("Reference:", test_dataset["sentence"][:2])
|
60 |
```
|
61 |
+
|
62 |
## Evaluation
|
63 |
+
|
64 |
The model can be evaluated as follows on the {language} test data of Common Voice.
|
65 |
+
|
66 |
```python
|
67 |
import torch
|
68 |
import torchaudio
|
|
|
74 |
processor = Wav2Vec2Processor.from_pretrained("manandey/wav2vec2-large-xlsr-assamese")
|
75 |
model = Wav2Vec2ForCTC.from_pretrained("manandey/wav2vec2-large-xlsr-assamese")
|
76 |
model.to("cuda")
|
77 |
+
chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\”\�\’\–\(\)\'\।]'
|
78 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
79 |
+
|
80 |
# Preprocessing the datasets.
|
81 |
# We need to read the aduio files as arrays
|
82 |
+
|
83 |
def speech_file_to_array_fn(batch):
|
84 |
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
85 |
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
|
|
98 |
result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
99 |
print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
|
100 |
```
|
101 |
+
|
102 |
**Test Result**: 74.25%
|
103 |
+
|
104 |
## Training
|
105 |
The Common Voice `train`, `validation` datasets were used for training.
|