Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Whisper ูุชุญููู ุงูุตูุช ุฅูู ูุต | |
| whisper = pipeline( | |
| "automatic-speech-recognition", | |
| model="openai/whisper-base" | |
| ) | |
| # ู ูุฏููู | |
| classifier = pipeline( | |
| "text-classification", | |
| model="MennatullahHany/Abert" | |
| ) | |
| label_map = { | |
| "LABEL_0": "Safe", | |
| "LABEL_1": "Danger" | |
| } | |
| def predict(audio): | |
| # ุชุญููู ุงูุตูุช ุฅูู ูุต | |
| transcription = whisper(audio)["text"] | |
| # ุชุดุบูู ุงูู ูุฏูู | |
| result = classifier(transcription)[0] | |
| label = label_map[result["label"]] | |
| return { | |
| "text":transcription, | |
| "result": label, | |
| "confidence": round(float(result["score"]), 4) | |
| } | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Audio(type="filepath", label="Upload Audio"), | |
| outputs=gr.JSON(label="Prediction"), | |
| title="Voice Emotion Detection", | |
| description="Upload an audio file to detect whether it is Safe or Danger." | |
| ) | |
| demo.launch() |