SLPL
/

SaraSadeghi commited on
Commit
aab5371
1 Parent(s): d3b048c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +124 -0
README.md CHANGED
@@ -1,3 +1,127 @@
1
  ---
 
 
 
 
 
 
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: fa
3
+ datasets:
4
+ - common_voice_9_0
5
+ tags:
6
+ - audio
7
+ - automatic-speech-recognition
8
  license: apache-2.0
9
+ #widget:
10
+ #- example_title: Librispeech sample 1
11
+ # src: https://cdn-media.huggingface.co/speech_samples/sample1.flac
12
+ #- example_title: Librispeech sample 2
13
+ # src: https://cdn-media.huggingface.co/speech_samples/sample2.flac
14
+ model-index:
15
+ - name: Sharif-wav2vec2
16
+ results:
17
+ - task:
18
+ name: Automatic Speech Recognition
19
+ type: automatic-speech-recognition
20
+ dataset:
21
+ name: Common Voice Corpus 9.0 (clean)
22
+ type: common_voice_9_0
23
+ config: clean
24
+ split: test
25
+ args:
26
+ language: fa
27
+ metrics:
28
+ - name: Test WER
29
+ type: wer
30
+ value: 6.0
31
+ #- task:
32
+ # name: Automatic Speech Recognition
33
+ # type: automatic-speech-recognition
34
+ # dataset:
35
+ # name: LibriSpeech (other)
36
+ # type: librispeech_asr
37
+ # config: other
38
+ # split: test
39
+ # args:
40
+ # language: en
41
+ # metrics:
42
+ # - name: Test WER
43
+ # type: wer
44
+ # value: 8.6
45
  ---
46
+
47
+ # Sharif-wav2vec2
48
+
49
+ [Sharif-wav2vec2](https://huggingface.co/SLPL/Sharif-wav2vec2/)
50
+
51
+ The base model fine-tuned on 960 hours of Librispeech on 16kHz sampled speech audio. When using the model
52
+ make sure that your speech input is also sampled at 16Khz.
53
+
54
+ [Paper](https://arxiv.org/abs/2006.11477)
55
+
56
+ Authors: Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli
57
+
58
+ **Abstract**
59
+
60
+ We show 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. wav2vec 2.0 masks the speech input in the latent space and solves a contrastive task defined over a quantization of the latent representations which are jointly learned. Experiments using all labeled data of Librispeech achieve 1.8/3.3 WER on the clean/other test sets. When lowering the amount of labeled data to one hour, wav2vec 2.0 outperforms the previous state of the art on the 100 hour subset while using 100 times less labeled data. Using just ten minutes of labeled data and pre-training on 53k hours of unlabeled data still achieves 4.8/8.2 WER. This demonstrates the feasibility of speech recognition with limited amounts of labeled data.
61
+
62
+ The original model can be found under https://github.com/pytorch/fairseq/tree/master/examples/wav2vec#wav2vec-20.
63
+
64
+
65
+ # Usage
66
+
67
+ To transcribe audio files the model can be used as a standalone acoustic model as follows:
68
+
69
+ ```python
70
+ from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
71
+ from datasets import load_dataset
72
+ import torch
73
+
74
+ # load model and tokenizer
75
+ processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
76
+ model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h")
77
+
78
+ # load dummy dataset and read soundfiles
79
+ ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
80
+
81
+ # tokenize
82
+ input_values = processor(ds[0]["audio"]["array"], return_tensors="pt", padding="longest").input_values # Batch size 1
83
+
84
+ # retrieve logits
85
+ logits = model(input_values).logits
86
+
87
+ # take argmax and decode
88
+ predicted_ids = torch.argmax(logits, dim=-1)
89
+ transcription = processor.batch_decode(predicted_ids)
90
+ ```
91
+
92
+ ## Evaluation
93
+
94
+ This code snippet shows how to evaluate **facebook/wav2vec2-base-960h** on LibriSpeech's "clean" and "other" test data.
95
+
96
+ ```python
97
+ from datasets import load_dataset
98
+ from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
99
+ import torch
100
+ from jiwer import wer
101
+
102
+
103
+ librispeech_eval = load_dataset("librispeech_asr", "clean", split="test")
104
+
105
+ model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h").to("cuda")
106
+ processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
107
+
108
+ def map_to_pred(batch):
109
+ input_values = processor(batch["audio"]["array"], return_tensors="pt", padding="longest").input_values
110
+ with torch.no_grad():
111
+ logits = model(input_values.to("cuda")).logits
112
+
113
+ predicted_ids = torch.argmax(logits, dim=-1)
114
+ transcription = processor.batch_decode(predicted_ids)
115
+ batch["transcription"] = transcription
116
+ return batch
117
+
118
+ result = librispeech_eval.map(map_to_pred, batched=True, batch_size=1, remove_columns=["audio"])
119
+
120
+ print("WER:", wer(result["text"], result["transcription"]))
121
+ ```
122
+
123
+ *Result (WER)*:
124
+
125
+ | "clean" | "other" |
126
+ |---|---|
127
+ | 3.4 | 8.6 |