Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,32 +13,32 @@ classifier = pipeline(
|
|
| 13 |
model="MennatullahHany/Abert"
|
| 14 |
)
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def predict(audio):
|
| 17 |
-
try:
|
| 18 |
-
# ุชุญููู ุงูุตูุช ุฅูู ูุต
|
| 19 |
-
transcription = whisper(audio)["text"]
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
-
"transcription": transcription,
|
| 29 |
-
"model_output": result
|
| 30 |
-
}
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
|
| 37 |
demo = gr.Interface(
|
| 38 |
fn=predict,
|
| 39 |
inputs=gr.Audio(type="filepath", label="Upload Audio"),
|
| 40 |
outputs=gr.JSON(label="Prediction"),
|
| 41 |
-
title="Voice Emotion Detection"
|
|
|
|
| 42 |
)
|
| 43 |
|
| 44 |
demo.launch()
|
|
|
|
| 13 |
model="MennatullahHany/Abert"
|
| 14 |
)
|
| 15 |
|
| 16 |
+
label_map = {
|
| 17 |
+
"LABEL_0": "Safe",
|
| 18 |
+
"LABEL_1": "Danger"
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
def predict(audio):
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
# ุชุญููู ุงูุตูุช ุฅูู ูุต
|
| 24 |
+
transcription = whisper(audio)["text"]
|
| 25 |
|
| 26 |
+
# ุชุดุบูู ุงูู
ูุฏูู
|
| 27 |
+
result = classifier(transcription)[0]
|
| 28 |
|
| 29 |
+
label = label_map[result["label"]]
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
return {
|
| 32 |
+
"emotion": label,
|
| 33 |
+
"confidence": round(float(result["score"]), 4)
|
| 34 |
+
}
|
| 35 |
|
| 36 |
demo = gr.Interface(
|
| 37 |
fn=predict,
|
| 38 |
inputs=gr.Audio(type="filepath", label="Upload Audio"),
|
| 39 |
outputs=gr.JSON(label="Prediction"),
|
| 40 |
+
title="Voice Emotion Detection",
|
| 41 |
+
description="Upload an audio file to detect whether it is Safe or Danger."
|
| 42 |
)
|
| 43 |
|
| 44 |
demo.launch()
|