import torchfrom transformers import WhisperProcessor, AutoModelForSpeechSeq2Seqfrom peft import PeftModelimport librosa # Load the model and processorprocessor = WhisperProcessor.from_pretrained("AbdelrahmanHassan/whisper-large-v3-egyptian-arabic")model = AutoModelForSpeechSeq2Seq.from_pretrained( "openai/whisper-large-v3", torch_dtype=torch.float16, low_cpu_mem_usage=True, use_safetensors=True) # Load the LoRA adaptermodel = PeftModel.from_pretrained(model, "AbdelrahmanHassan/whisper-large-v3-egyptian-arabic") # Load and process audioaudio, sr = librosa.load("path_to_audio.wav", sr=16000)input_features = processor(audio, sampling_rate=16000, return_tensors="pt").input_features # Generate transcriptionwith torch.no_grad(): predicted_ids = model.generate(input_features, max_length=225) transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0] print(transcription)