patrickvonplaten commited on
Commit
c0b7a4a
1 Parent(s): 5962bda

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +1 -9
README.md CHANGED
@@ -81,7 +81,6 @@ To transcribe audio files the model can be used as a standalone acoustic model a
81
  ```python
82
  from datasets import load_dataset
83
  from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
84
- import soundfile as sf
85
  import torch
86
  from jiwer import wer
87
 
@@ -91,15 +90,8 @@ librispeech_eval = load_dataset("librispeech_asr", "clean", split="test")
91
  model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h").to("cuda")
92
  processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
93
 
94
- def map_to_array(batch):
95
- speech, _ = sf.read(batch["file"])
96
- batch["speech"] = speech
97
- return batch
98
-
99
- librispeech_eval = librispeech_eval.map(map_to_array)
100
-
101
  def map_to_pred(batch):
102
- input_values = processor(batch["speech"], return_tensors="pt", padding="longest").input_values
103
  with torch.no_grad():
104
  logits = model(input_values.to("cuda")).logits
105
 
 
81
  ```python
82
  from datasets import load_dataset
83
  from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
 
84
  import torch
85
  from jiwer import wer
86
 
 
90
  model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h").to("cuda")
91
  processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
92
 
 
 
 
 
 
 
 
93
  def map_to_pred(batch):
94
+ input_values = processor(batch["audio"]["array"], return_tensors="pt", padding="longest").input_values
95
  with torch.no_grad():
96
  logits = model(input_values.to("cuda")).logits
97