Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,8 @@ def classify_emotion():
|
|
44 |
#### Emotion classification ####
|
45 |
emotion_classifier = foreign_class(source="speechbrain/emotion-recognition-wav2vec2-IEMOCAP", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
|
46 |
out_prob, score, index, text_lab = emotion_classifier.classify_file(audio_file)
|
47 |
-
|
|
|
48 |
|
49 |
# Create a Gradio interface with audio file and text inputs
|
50 |
def classify_toxicity(audio_file, text_input, classify_anxiety):
|
@@ -64,7 +65,9 @@ def classify_toxicity(audio_file, text_input, classify_anxiety):
|
|
64 |
|
65 |
toxicity_score = toxicity_results["toxicity"][0]
|
66 |
print(toxicity_score)
|
67 |
-
|
|
|
|
|
68 |
#### Text classification #####
|
69 |
|
70 |
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
@@ -118,12 +121,13 @@ def classify_toxicity(audio_file, text_input, classify_anxiety):
|
|
118 |
with gr.Blocks() as iface:
|
119 |
with gr.Column():
|
120 |
anxiety_class = gr.Radio(["racism", "LGBTQ+ hate", "sexually explicit", "misophonia"])
|
|
|
121 |
with gr.Column():
|
122 |
aud_input = gr.Audio(source="upload", type="filepath", label="Upload Audio File")
|
123 |
text = gr.Textbox(label="Enter Text", placeholder="Enter text here...")
|
124 |
submit_btn = gr.Button(label="Run")
|
125 |
with gr.Column():
|
126 |
out_text = gr.Textbox()
|
127 |
-
submit_btn.click(fn=classify_toxicity, inputs=[aud_input, text, anxiety_class], outputs=out_text)
|
128 |
|
129 |
iface.launch()
|
|
|
44 |
#### Emotion classification ####
|
45 |
emotion_classifier = foreign_class(source="speechbrain/emotion-recognition-wav2vec2-IEMOCAP", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
|
46 |
out_prob, score, index, text_lab = emotion_classifier.classify_file(audio_file)
|
47 |
+
emostr = "emo class"
|
48 |
+
return emo_dict[text_lab[0]], emostr
|
49 |
|
50 |
# Create a Gradio interface with audio file and text inputs
|
51 |
def classify_toxicity(audio_file, text_input, classify_anxiety):
|
|
|
65 |
|
66 |
toxicity_score = toxicity_results["toxicity"][0]
|
67 |
print(toxicity_score)
|
68 |
+
# emo call
|
69 |
+
if emo_class != None:
|
70 |
+
classify_emotion()
|
71 |
#### Text classification #####
|
72 |
|
73 |
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
|
|
121 |
with gr.Blocks() as iface:
|
122 |
with gr.Column():
|
123 |
anxiety_class = gr.Radio(["racism", "LGBTQ+ hate", "sexually explicit", "misophonia"])
|
124 |
+
emo_class = gr.Radio(choices=["negaitve emotionality"], label="label", info="info")
|
125 |
with gr.Column():
|
126 |
aud_input = gr.Audio(source="upload", type="filepath", label="Upload Audio File")
|
127 |
text = gr.Textbox(label="Enter Text", placeholder="Enter text here...")
|
128 |
submit_btn = gr.Button(label="Run")
|
129 |
with gr.Column():
|
130 |
out_text = gr.Textbox()
|
131 |
+
submit_btn.click(fn=classify_toxicity, inputs=[aud_input, text, anxiety_class, emo_class], outputs=out_text)
|
132 |
|
133 |
iface.launch()
|