SLPL
/

sadrasabouri commited on
Commit
7f1534d
1 Parent(s): 02ec3bf

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -69
README.md CHANGED
@@ -72,75 +72,6 @@ print(prediction[0])
72
  ```
73
 
74
 
75
- # Authors: Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli
76
-
77
- # **Abstract**
78
-
79
- <!--
80
- 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.
81
- -->
82
-
83
- The original model can be found under https://github.com/pytorch/fairseq/tree/master/examples/wav2vec#wav2vec-20.
84
-
85
-
86
- # Usage
87
-
88
- To transcribe Persian audio files the model can be used as a standalone acoustic model as follows:
89
-
90
- ```python
91
- from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
92
- from datasets import load_dataset
93
- import torch
94
-
95
- # load model and tokenizer
96
- processor = Wav2Vec2Processor.from_pretrained("SLPL/Sharif-wav2vec2")
97
- model = Wav2Vec2ForCTC.from_pretrained("SLPL/Sharif-wav2vec2")
98
-
99
- # load dummy dataset and read soundfiles
100
- # ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
101
-
102
- # tokenize
103
- input_values = processor(ds[0]["audio"]["array"], return_tensors="pt", padding="longest").input_values # Batch size 1
104
-
105
- # retrieve logits
106
- logits = model(input_values).logits
107
-
108
- # take argmax and decode
109
- predicted_ids = torch.argmax(logits, dim=-1)
110
- transcription = processor.batch_decode(predicted_ids)
111
- ```
112
-
113
- ## Evaluation
114
-
115
- This code snippet shows how to evaluate **facebook/wav2vec2-base-960h** on LibriSpeech's "clean" and "other" test data.
116
-
117
- ```python
118
- from datasets import load_dataset
119
- from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
120
- import torch
121
- from jiwer import wer
122
-
123
-
124
- librispeech_eval = load_dataset("librispeech_asr", "clean", split="test")
125
-
126
- model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h").to("cuda")
127
- processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
128
-
129
- def map_to_pred(batch):
130
- input_values = processor(batch["audio"]["array"], return_tensors="pt", padding="longest").input_values
131
- with torch.no_grad():
132
- logits = model(input_values.to("cuda")).logits
133
-
134
- predicted_ids = torch.argmax(logits, dim=-1)
135
- transcription = processor.batch_decode(predicted_ids)
136
- batch["transcription"] = transcription
137
- return batch
138
-
139
- result = librispeech_eval.map(map_to_pred, batched=True, batch_size=1, remove_columns=["audio"])
140
-
141
- print("WER:", wer(result["text"], result["transcription"]))
142
- ```
143
-
144
  *Result (WER)*:
145
 
146
  | "clean" | "other" |
 
72
  ```
73
 
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  *Result (WER)*:
76
 
77
  | "clean" | "other" |