Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,10 +42,10 @@ class_options = {
|
|
| 42 |
pipe = pipeline("automatic-speech-recognition", model="openai/whisper-large")
|
| 43 |
|
| 44 |
def classify_emotion(audio):
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
# Create a Gradio interface with audio file and text inputs
|
| 51 |
def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, explitive_selection):
|
|
@@ -55,7 +55,7 @@ def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, expli
|
|
| 55 |
else:
|
| 56 |
transcribed_text = text_input
|
| 57 |
if classify_anxiety != "misophonia":
|
| 58 |
-
|
| 59 |
# explitive call
|
| 60 |
if replace_explitives != None and emo_class == None:
|
| 61 |
transcribed_text = replace_explitives.sub_explitives(transcribed_text, explitive_selection)
|
|
|
|
| 42 |
pipe = pipeline("automatic-speech-recognition", model="openai/whisper-large")
|
| 43 |
|
| 44 |
def classify_emotion(audio):
|
| 45 |
+
#### Emotion classification ####
|
| 46 |
+
emotion_classifier = foreign_class(source="speechbrain/emotion-recognition-wav2vec2-IEMOCAP", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
|
| 47 |
+
out_prob, score, index, text_lab = emotion_classifier.classify_file(audio)
|
| 48 |
+
return emo_dict[text_lab[0]]
|
| 49 |
|
| 50 |
# Create a Gradio interface with audio file and text inputs
|
| 51 |
def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, explitive_selection):
|
|
|
|
| 55 |
else:
|
| 56 |
transcribed_text = text_input
|
| 57 |
if classify_anxiety != "misophonia":
|
| 58 |
+
print("emo_class ", emo_class, "explitive select", explitive_selection)
|
| 59 |
# explitive call
|
| 60 |
if replace_explitives != None and emo_class == None:
|
| 61 |
transcribed_text = replace_explitives.sub_explitives(transcribed_text, explitive_selection)
|