Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,7 +49,7 @@ def classify_emotion(audio):
|
|
| 49 |
return emo_dict[text_lab[0]]
|
| 50 |
|
| 51 |
# Create a Gradio interface with audio file and text inputs
|
| 52 |
-
def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, explitive_selection):
|
| 53 |
# Transcribe the audio file using Whisper ASR
|
| 54 |
if audio_file != None:
|
| 55 |
transcribed_text = pipe(audio_file)["text"]
|
|
@@ -57,6 +57,8 @@ def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, expli
|
|
| 57 |
transcribed_text = text_input
|
| 58 |
if classify_anxiety != "misophonia":
|
| 59 |
print("emo_class ", emo_class, "explitive select", explitive_selection)
|
|
|
|
|
|
|
| 60 |
|
| 61 |
#------- explitive call ---------------
|
| 62 |
|
|
@@ -134,6 +136,7 @@ with gr.Blocks() as iface:
|
|
| 134 |
anxiety_class = gr.Radio(["racism", "LGBTQ+ hate", "sexually explicit", "misophonia"])
|
| 135 |
explit_preference = gr.Radio(choices=["N-Word", "B-Word", "All Explitives"], label="Words to omit from general anxiety classes", info="certain words may be acceptible within certain contects for given groups of people, and some people may be unbothered by explitives broadly speaking.")
|
| 136 |
emo_class = gr.Radio(choices=["negaitve emotionality"], label="label", info="Select if you would like explitives to be considered anxiety-indiucing in the case of anger/ negative emotionality.")
|
|
|
|
| 137 |
with gr.Column():
|
| 138 |
aud_input = gr.Audio(source="upload", type="filepath", label="Upload Audio File")
|
| 139 |
text = gr.Textbox(label="Enter Text", placeholder="Enter text here...")
|
|
@@ -142,6 +145,6 @@ with gr.Blocks() as iface:
|
|
| 142 |
out_val = gr.Textbox()
|
| 143 |
out_class = gr.Textbox()
|
| 144 |
out_text = gr.Textbox()
|
| 145 |
-
submit_btn.click(fn=classify_toxicity, inputs=[aud_input, text, anxiety_class, emo_class, explit_preference], outputs=[out_val,
|
| 146 |
|
| 147 |
iface.launch()
|
|
|
|
| 49 |
return emo_dict[text_lab[0]]
|
| 50 |
|
| 51 |
# Create a Gradio interface with audio file and text inputs
|
| 52 |
+
def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, explitive_selection, slider):
|
| 53 |
# Transcribe the audio file using Whisper ASR
|
| 54 |
if audio_file != None:
|
| 55 |
transcribed_text = pipe(audio_file)["text"]
|
|
|
|
| 57 |
transcribed_text = text_input
|
| 58 |
if classify_anxiety != "misophonia":
|
| 59 |
print("emo_class ", emo_class, "explitive select", explitive_selection)
|
| 60 |
+
|
| 61 |
+
## SLIDER ##
|
| 62 |
|
| 63 |
#------- explitive call ---------------
|
| 64 |
|
|
|
|
| 136 |
anxiety_class = gr.Radio(["racism", "LGBTQ+ hate", "sexually explicit", "misophonia"])
|
| 137 |
explit_preference = gr.Radio(choices=["N-Word", "B-Word", "All Explitives"], label="Words to omit from general anxiety classes", info="certain words may be acceptible within certain contects for given groups of people, and some people may be unbothered by explitives broadly speaking.")
|
| 138 |
emo_class = gr.Radio(choices=["negaitve emotionality"], label="label", info="Select if you would like explitives to be considered anxiety-indiucing in the case of anger/ negative emotionality.")
|
| 139 |
+
sense_slider = gr.Slider(minimum=1, maximum=5, label="How readily do you want the tool to intervene? 1 = in extreme cases and 5 = at every opportunity")
|
| 140 |
with gr.Column():
|
| 141 |
aud_input = gr.Audio(source="upload", type="filepath", label="Upload Audio File")
|
| 142 |
text = gr.Textbox(label="Enter Text", placeholder="Enter text here...")
|
|
|
|
| 145 |
out_val = gr.Textbox()
|
| 146 |
out_class = gr.Textbox()
|
| 147 |
out_text = gr.Textbox()
|
| 148 |
+
submit_btn.click(fn=classify_toxicity, inputs=[aud_input, text, anxiety_class, emo_class, explit_preference, sense_slider], outputs=[out_val, out_class, out_text])
|
| 149 |
|
| 150 |
iface.launch()
|