Automatic Speech Recognition
Transformers
PyTorch
English
speech_to_text_transformer
text-generation
audio
Run this model with HF Jobs
Run valhalla/s2t_librispeech_medium on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/valhalla/s2t_librispeech_medium. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/valhalla/s2t_librispeech_medium on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use valhalla/s2t_librispeech_medium with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use valhalla/s2t_librispeech_medium with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="valhalla/s2t_librispeech_medium")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("valhalla/s2t_librispeech_medium", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Commit ·
f84b430
1
Parent(s): db24822
Create README.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354---language: endatasets:- librispeech_asrtags:- audio- automatic-speech-recognitionlicense: apache-2.0---
TODO: [To be filled]
## Evaluation on LibriSpeech Test
The following script shows how to evaluate this model on the [LibriSpeech](https://huggingface.co/datasets/librispeech_asr) *"clean"* and *"other"* dataset.
```pythonfrom datasets import load_datasetfrom transformers import Speech2TextTransformerForConditionalGeneration, Speech2TextTransformerTokenizerimport soundfile as sffrom jiwer import wer
librispeech_eval = load_dataset("librispeech_asr", "clean", split="test") # change to "other" for other test dataset
model = Speech2TextTransformerForConditionalGeneration.from_pretrained("valhalla/s2t_librispeech_medium").to("cuda")tokenizer = Speech2TextTransformerTokenizer.from_pretrained("valhalla/s2t_librispeech_medium", do_upper_case=True)
def map_to_array(batch): speech, _ = sf.read(batch["file"]) batch["speech"] = speech return batch
librispeech_eval = librispeech_eval.map(map_to_array)
def map_to_pred(batch): features = tokenizer(batch["speech"], sample_rate=16000, padding=True, return_tensors="pt") input_features = features.input_features.to("cuda") attention_mask = features.attention_mask.to("cuda")
gen_tokens = model.generate(input_ids=input_features, attention_mask=attention_mask) batch["transcription"] = tokenizer.batch_decode(gen_tokens, skip_special_tokens=True) return batch
result = librispeech_eval.map(map_to_pred, batched=True, batch_size=8, remove_columns=["speech"])
print("WER:", wer(result["text"], result["transcription"]))```
*Result (WER)*:
| "clean" | "other" ||---|---|| 3.5 | 7.8 |README.mdAdded+54