import torch import librosa from transformers import WhisperProcessor, pipeline def predict_from_file(audio_path, model_name="ahmad1703/whis_ee"): Make a prediction using the WhisperClassifier model Args: audio_path: Path to the audio file model_name: The Hugging Face model name Returns: Prediction (0 or 1) # Load audio audio, sr = librosa.load(audio_path, sr=16000) # Create pipeline classifier = pipeline("audio-classification", model=model_name) # Get prediction result = classifier(audio) # Convert probability to binary class prediction = 1 if result["score"] > 0.5 else 0 return prediction if __name__ == "__main__": # Example usage audio_path = "example.wav" # Replace with your audio file prediction = predict_from_file(audio_path) print(f"Prediction: {prediction}")