Views
No views yet
peft library to load the LoRA adapter weights:1from transformers import WhisperProcessor, WhisperForConditionalGeneration
2from peft import PeftModel
3import torch
4
5# Load base model and processor
6base_model_name = "openai/whisper-large-v3"
7processor = WhisperProcessor.from_pretrained(base_model_name)
8base_model = WhisperForConditionalGeneration.from_pretrained(base_model_name)
9
10# Load LoRA adapter
11model = PeftModel.from_pretrained(base_model, "WernL/whisper-afrikaans-whisper_training_1756041291")
12
13# Load audio
14import librosa
15audio, sr = librosa.load("path_to_audio.wav", sr=16000)
16
17# Process
18input_features = processor(audio, sampling_rate=16000, return_tensors="pt").input_features
19predicted_ids = model.generate(input_features)
20transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
21print(transcription[0])1from transformers import pipeline
2
3# This may work if the adapter is properly configured
4pipe = pipeline("automatic-speech-recognition", model="WernL/whisper-afrikaans-whisper_training_1756041291")
5result = pipe("path_to_audio.wav")
6print(result["text"])