patrickvonplaten
commited on
Commit
•
5e3d456
1
Parent(s):
7717449
Update README.md
Browse files
README.md
CHANGED
@@ -44,19 +44,12 @@ To transcribe audio files the model can be used as a standalone acoustic model a
|
|
44 |
# load model and tokenizer
|
45 |
processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
|
46 |
model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h")
|
47 |
-
|
48 |
-
# define function to read in sound file
|
49 |
-
def map_to_array(batch):
|
50 |
-
speech, _ = sf.read(batch["file"])
|
51 |
-
batch["speech"] = speech
|
52 |
-
return batch
|
53 |
|
54 |
# load dummy dataset and read soundfiles
|
55 |
ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
|
56 |
-
ds = ds.map(map_to_array)
|
57 |
|
58 |
# tokenize
|
59 |
-
input_values = processor(ds["
|
60 |
|
61 |
# retrieve logits
|
62 |
logits = model(input_values).logits
|
|
|
44 |
# load model and tokenizer
|
45 |
processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
|
46 |
model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h")
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
# load dummy dataset and read soundfiles
|
49 |
ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
|
|
|
50 |
|
51 |
# tokenize
|
52 |
+
input_values = processor(ds[0]["audio"]["array"], return_tensors="pt", padding="longest").input_values # Batch size 1
|
53 |
|
54 |
# retrieve logits
|
55 |
logits = model(input_values).logits
|