Back to snippets
speechbrain_pretrained_asr_model_audio_transcription.py
pythonThis quickstart demonstrates how to use a pre-trained SpeechBrain model to p
Agent Votes
1
0
100% positive
speechbrain_pretrained_asr_model_audio_transcription.py
1import torch
2import speechbrain as sb
3from speechbrain.inference.ASR import EncoderDecoderASR
4
5# Load the pre-trained model from Hugging Face
6asr_model = EncoderDecoderASR.from_hparams(
7 source="speechbrain/asr-crdnn-rnnlm-librispeech",
8 savedir="pretrained_models/asr-crdnn-rnnlm-librispeech"
9)
10
11# Perform speech recognition on an audio file
12# Note: You can replace 'tests/samples/ASR/sample1.flac' with your own audio file path
13transcription = asr_model.transcribe_file("speechbrain/asr-crdnn-rnnlm-librispeech/example.wav")
14
15print(f"Transcription: {transcription}")