Views
No views yet
aiola/whisper-medusa-block-libri was trained on the LibriSpeech dataset to perform audio translation.
The Medusa heads were optimized for English, so for optimal performance and speed improvements, please use English audio only.aiola/whisper-medusa-block-libri install whisper-medusa repo following the README instructions.1import torch
2import torchaudio
3
4from whisper_medusa import WhisperMedusaModel
5from transformers import WhisperProcessor
6
7model_name = "aiola/whisper-medusa-block-libri"
8model = WhisperMedusaModel.from_pretrained(model_name)
9processor = WhisperProcessor.from_pretrained(model_name)
10
11path_to_audio = "path/to/audio.wav"
12SAMPLING_RATE = 16000
13language = "en"
14device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
16input_speech, sr = torchaudio.load(path_to_audio)
17if sr != SAMPLING_RATE:
18 input_speech = torchaudio.transforms.Resample(sr, SAMPLING_RATE)(input_speech)
19
20input_features = processor(input_speech.squeeze(), return_tensors="pt", sampling_rate=SAMPLING_RATE).input_features
21input_features = input_features.to(device)
22
23model = model.to(device)
24model_output = model.generate(
25 input_features,
26 language=language,
27)
28predict_ids = model_output[0]
29pred = processor.decode(predict_ids, skip_special_tokens=True)
30print(pred)
31