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
update weights
Browse filesFiles changed (2)
- .ipynb_checkpoints/config-checkpoint.jsonAdded+45
- README.mdAdded+54
123456789101112131415161718192021222324252627282930313233343536373839404142434445{ "activation_dropout": 0.15, "activation_function": "relu", "architectures": [ "Speech2TextTransformerForConditionalGeneration" ], "attention_dropout": 0.15, "bos_token_id": 0, "classifier_dropout": 0.0, "conv_channels": 1024, "conv_kernel_sizes": [ 5, 5 ], "d_model": 512, "decoder_attention_heads": 8, "decoder_ffn_dim": 2048, "decoder_layerdrop": 0.0, "decoder_layers": 6, "decoder_start_token_id": 2, "dropout": 0.15, "early_stopping": true, "encoder_attention_heads": 8, "encoder_ffn_dim": 2048, "encoder_layerdrop": 0.0, "encoder_layers": 12, "eos_token_id": 2, "gradient_checkpointing": false, "init_std": 0.02, "input_channels": 1, "input_feat_per_channel": 80, "is_encoder_decoder": true, "max_length": 200, "max_source_positions": 6000, "max_target_positions": 1024, "model_type": "speech_to_text_transformer", "num_beams": 5, "num_conv_layers": 2, "num_hidden_layers": 12, "pad_token_id": 1, "scale_embedding": true, "transformers_version": "4.4.0.dev0", "use_cache": true, "vocab_size": 10000}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354---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"* test 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 |.ipynb_checkpoints/config-checkpoint.jsonAdded+45
README.mdAdded+54