Downloads · 30 days
23
0% of all-time downloads
patrickvonplaten/wav2vec2-base-960h-4-gram
wav2vec2-base-960h-4-gram is a automatic speech recognition model from patrickvonplaten. Use it when you need speech turned into text. It is set up for transformers. The card lists the license as apache-2.0.
This model is identical to Facebook's Wav2Vec2-Base-960h, but is augmented with an English 4-gram. The 4-gram.arpa.gz of Librispeech's official ngrams is used.
Downloads · 30 days
23
0% of all-time downloads
All-time downloads
6.2K
Public
Repo size
4.3 GB
Likes
0
Public
Click a slice to open those files.
.bin3.5 GB · 90%
From the Hugging Face model README
This model is identical to Facebook's Wav2Vec2-Base-960h, but is
augmented with an English 4-gram. The 4-gram.arpa.gz of Librispeech's official ngrams is used.
This code snippet shows how to evaluate patrickvonplaten/wav2vec2-base-960h-4-gram on LibriSpeech's "clean" and "other" test data.
from datasets import load_dataset
from transformers import AutoModelForCTC, AutoProcessor
import torch
from jiwer import wer
model_id = "patrickvonplaten/wav2vec2-base-960h-4-gram"
librispeech_eval = load_dataset("librispeech_asr", "other", split="test")
model = AutoModelForCTC.from_pretrained(model_id).to("cuda")
processor = AutoProcessor.from_pretrained(model_id)
def map_to_pred(batch):
inputs = processor(batch["audio"]["array"], sampling_rate=16_000, return_tensors="pt")
inputs = {k: v.to("cuda") for k,v in inputs.items()}
with torch.no_grad():
logits = model(**inputs).logits
transcription = processor.batch_decode(logits.cpu().numpy()).text[0]
batch["transcription"] = transcription
return batch
result = librispeech_eval.map(map_to_pred, remove_columns=["audio"])
print(wer(result["text"], result["transcription"]))
Result (WER):
| "clean" | "other" |
|---|---|
| 2.59 | 6.46 |