Commit
·
8b4a6d2
1
Parent(s):
9fb9fb3
Update my model
Browse files- 3gram.zip → 3gram.bin.zip +0 -0
- 4gram.zip → 4gram.bin.zip +0 -0
- README.md +32 -140
3gram.zip → 3gram.bin.zip
RENAMED
File without changes
|
4gram.zip → 4gram.bin.zip
RENAMED
File without changes
|
README.md
CHANGED
@@ -1,142 +1,34 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
model
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
type: automatic-speech-recognition
|
34 |
-
dataset:
|
35 |
-
name: VIVOS
|
36 |
-
type: vivos
|
37 |
-
args: vi
|
38 |
-
metrics:
|
39 |
-
- name: Test WER
|
40 |
-
type: wer
|
41 |
-
value: 6.15
|
42 |
-
---
|
43 |
-
|
44 |
-
# Vietnamese end-to-end speech recognition using wav2vec 2.0
|
45 |
-
|
46 |
-
[](https://paperswithcode.com/sota/speech-recognition-on-common-voice-vi?p=vietnamese-end-to-end-speech-recognition)
|
47 |
-
|
48 |
-
[](https://paperswithcode.com/sota/speech-recognition-on-vivos?p=vietnamese-end-to-end-speech-recognition)
|
49 |
-
|
50 |
-
|
51 |
-
[Facebook's Wav2Vec2](https://ai.facebook.com/blog/wav2vec-20-learning-the-structure-of-speech-from-raw-audio/)
|
52 |
-
|
53 |
-
### Model description
|
54 |
-
|
55 |
-
[Our models](https://huggingface.co/nguyenvulebinh/wav2vec2-base-vietnamese-250h) are pre-trained on 13k hours of Vietnamese youtube audio (un-label data) and fine-tuned on 250 hours labeled of [VLSP ASR dataset](https://vlsp.org.vn/vlsp2020/eval/asr) on 16kHz sampled speech audio.
|
56 |
-
|
57 |
-
We use [wav2vec2 architecture](https://ai.facebook.com/blog/wav2vec-20-learning-the-structure-of-speech-from-raw-audio/) for the pre-trained model. Follow wav2vec2 paper:
|
58 |
-
|
59 |
-
>For the first time that learning powerful representations from speech audio alone followed by fine-tuning on transcribed speech can outperform the best semi-supervised methods while being conceptually simpler.
|
60 |
-
|
61 |
-
For fine-tuning phase, wav2vec2 is fine-tuned using Connectionist Temporal Classification (CTC), which is an algorithm that is used to train neural networks for sequence-to-sequence problems and mainly in Automatic Speech Recognition and handwriting recognition.
|
62 |
-
|
63 |
-
| Model | #params | Pre-training data | Fine-tune data |
|
64 |
-
|---|---|---|---|
|
65 |
-
| [base]((https://huggingface.co/nguyenvulebinh/wav2vec2-base-vietnamese-250h)) | 95M | 13k hours | 250 hours |
|
66 |
-
|
67 |
-
In a formal ASR system, two components are required: acoustic model and language model. Here ctc-wav2vec fine-tuned model works as an acoustic model. For the language model, we provide a [4-grams model](https://huggingface.co/nguyenvulebinh/wav2vec2-base-vietnamese-250h/blob/main/vi_lm_4grams.bin.zip) trained on 2GB of spoken text.
|
68 |
-
|
69 |
-
Detail of training and fine-tuning process, the audience can follow [fairseq github](https://github.com/pytorch/fairseq/tree/master/examples/wav2vec) and [huggingface blog](https://huggingface.co/blog/fine-tune-wav2vec2-english).
|
70 |
-
|
71 |
-
### Benchmark WER result:
|
72 |
-
|
73 |
-
| | [VIVOS](https://ailab.hcmus.edu.vn/vivos) | [COMMON VOICE VI](https://paperswithcode.com/dataset/common-voice) | [VLSP-T1](https://vlsp.org.vn/vlsp2020/eval/asr) | [VLSP-T2](https://vlsp.org.vn/vlsp2020/eval/asr) |
|
74 |
-
|---|---|---|---|---|
|
75 |
-
|without LM| 10.77 | 18.34 | 13.33 | 51.45 |
|
76 |
-
|with 4-grams LM| 6.15 | 11.52 | 9.11 | 40.81 |
|
77 |
-
|
78 |
-
|
79 |
-
### Example usage
|
80 |
-
|
81 |
-
When using the model make sure that your speech input is sampled at 16Khz. Audio length should be shorter than 10s. Following the Colab link below to use a combination of CTC-wav2vec and 4-grams LM.
|
82 |
-
|
83 |
-
[](https://colab.research.google.com/drive/1pVBY46gSoWer2vDf0XmZ6uNV3d8lrMxx?usp=sharing)
|
84 |
-
|
85 |
-
|
86 |
-
```python
|
87 |
-
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
|
88 |
-
from datasets import load_dataset
|
89 |
-
import soundfile as sf
|
90 |
-
import torch
|
91 |
-
|
92 |
-
# load model and tokenizer
|
93 |
-
processor = Wav2Vec2Processor.from_pretrained("nguyenvulebinh/wav2vec2-base-vietnamese-250h")
|
94 |
-
model = Wav2Vec2ForCTC.from_pretrained("nguyenvulebinh/wav2vec2-base-vietnamese-250h")
|
95 |
-
|
96 |
-
# define function to read in sound file
|
97 |
-
def map_to_array(batch):
|
98 |
-
speech, _ = sf.read(batch["file"])
|
99 |
-
batch["speech"] = speech
|
100 |
-
return batch
|
101 |
-
|
102 |
-
# load dummy dataset and read soundfiles
|
103 |
-
ds = map_to_array({
|
104 |
-
"file": 'audio-test/t1_0001-00010.wav'
|
105 |
-
})
|
106 |
-
|
107 |
-
# tokenize
|
108 |
-
input_values = processor(ds["speech"], return_tensors="pt", padding="longest").input_values # Batch size 1
|
109 |
-
|
110 |
-
# retrieve logits
|
111 |
-
logits = model(input_values).logits
|
112 |
-
|
113 |
-
# take argmax and decode
|
114 |
-
predicted_ids = torch.argmax(logits, dim=-1)
|
115 |
-
transcription = processor.batch_decode(predicted_ids)
|
116 |
-
```
|
117 |
-
|
118 |
-
### Model Parameters License
|
119 |
-
|
120 |
-
The ASR model parameters are made available for non-commercial use only, under the terms of the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license. You can find details at: https://creativecommons.org/licenses/by-nc/4.0/legalcode
|
121 |
-
|
122 |
-
### Citation
|
123 |
-
|
124 |
-
[](https://github.com/vietai/ASR)
|
125 |
-
|
126 |
-
```text
|
127 |
-
@misc{Thai_Binh_Nguyen_wav2vec2_vi_2021,
|
128 |
-
author = {Thai Binh Nguyen},
|
129 |
-
doi = {10.5281/zenodo.5356039},
|
130 |
-
month = {09},
|
131 |
-
title = {{Vietnamese end-to-end speech recognition using wav2vec 2.0}},
|
132 |
-
url = {https://github.com/vietai/ASR},
|
133 |
-
year = {2021}
|
134 |
-
}
|
135 |
```
|
136 |
-
**Please CITE** our repo when it is used to help produce published results or is incorporated into other software.
|
137 |
-
|
138 |
-
# Contact
|
139 |
-
|
140 | |
141 |
|
142 |
-
[](https://twitter.com/intent/follow?screen_name=nguyenvulebinh)
|
|
|
1 |
+
Convert from model .pt to transformer
|
2 |
+
Link: https://huggingface.co/tommy19970714/wav2vec2-base-960h
|
3 |
+
Bash:
|
4 |
+
```bash
|
5 |
+
pip install transformers[sentencepiece]
|
6 |
+
pip install fairseq -U
|
7 |
+
git clone https://github.com/huggingface/transformers.git
|
8 |
+
cp transformers/src/transformers/models/wav2vec2/convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py .
|
9 |
+
wget https://dl.fbaipublicfiles.com/fairseq/wav2vec/wav2vec_small.pt -O ./wav2vec_small.pt
|
10 |
+
mkdir dict
|
11 |
+
wget https://dl.fbaipublicfiles.com/fairseq/wav2vec/dict.ltr.txt
|
12 |
+
mkdir outputs
|
13 |
+
python convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py
|
14 |
+
--pytorch_dump_folder_path ./outputs --checkpoint_path ./finetuned/wav2vec_small.pt
|
15 |
+
--dict_path ./dict/dict.ltr.txt --not_finetuned
|
16 |
+
```
|
17 |
+
# install and upload model
|
18 |
+
```
|
19 |
+
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
|
20 |
+
git lfs install
|
21 |
+
sudo apt-get install git-lfs
|
22 |
+
git lfs install
|
23 |
+
git clone https://huggingface.co/hoangbinhmta99/wav2vec-demo
|
24 |
+
ls
|
25 |
+
cd wav2vec-demo/
|
26 |
+
git status
|
27 |
+
git add .
|
28 |
+
git commit -m "First model version"
|
29 |
+
git config --global user.email [yourname]
|
30 |
+
git config --global user.name [yourpass]
|
31 |
+
git commit -m "First model version"
|
32 |
+
git push
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
```
|
|
|
|
|
|
|
|
|
|
|
34 |
|
|