mskov commited on
Commit
95b70d7
·
1 Parent(s): 4546c54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -65,7 +65,7 @@ def slider_logic(slider):
65
  return threshold
66
 
67
  # Create a Gradio interface with audio file and text inputs
68
- def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, explitive_selection, slider):
69
  # Transcribe the audio file using Whisper ASR
70
  if audio_file != None:
71
  transcribed_text = pipe(audio_file)["text"]
@@ -114,7 +114,7 @@ def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, expli
114
 
115
  # plot.update(x=classification_df["labels"], y=classification_df["scores"])
116
  if toxicity_score > threshold:
117
- print("threshold exceeded!!")
118
 
119
  return toxicity_score, classification_output, transcribed_text
120
  # return f"Toxicity Score ({available_models[selected_model]}): {toxicity_score:.4f}"
@@ -150,7 +150,8 @@ def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, expli
150
  average_logprobs -= internal_lm_average_logprobs
151
  scores = average_logprobs.softmax(-1).tolist()
152
  return {class_name: score for class_name, score in zip(class_names, scores)}
153
-
 
154
  return classify_anxiety
155
 
156
  with gr.Blocks() as iface:
@@ -159,6 +160,7 @@ with gr.Blocks() as iface:
159
  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.")
160
  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.")
161
  sense_slider = gr.Slider(minimum=1, maximum=5, step=1.0, label="How readily do you want the tool to intervene? 1 = in extreme cases and 5 = at every opportunity")
 
162
  with gr.Column():
163
  aud_input = gr.Audio(source="upload", type="filepath", label="Upload Audio File")
164
  text = gr.Textbox(label="Enter Text", placeholder="Enter text here...")
@@ -167,6 +169,6 @@ with gr.Blocks() as iface:
167
  out_val = gr.Textbox()
168
  out_class = gr.Textbox()
169
  out_text = gr.Textbox()
170
- 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])
171
 
172
  iface.launch()
 
65
  return threshold
66
 
67
  # Create a Gradio interface with audio file and text inputs
68
+ def classify_toxicity(audio_file, text_input, classify_anxiety, emo_class, explitive_selection, slider, intervention):
69
  # Transcribe the audio file using Whisper ASR
70
  if audio_file != None:
71
  transcribed_text = pipe(audio_file)["text"]
 
114
 
115
  # plot.update(x=classification_df["labels"], y=classification_df["scores"])
116
  if toxicity_score > threshold:
117
+ print("threshold exceeded!! Launch intervention")
118
 
119
  return toxicity_score, classification_output, transcribed_text
120
  # return f"Toxicity Score ({available_models[selected_model]}): {toxicity_score:.4f}"
 
150
  average_logprobs -= internal_lm_average_logprobs
151
  scores = average_logprobs.softmax(-1).tolist()
152
  return {class_name: score for class_name, score in zip(class_names, scores)}
153
+ if toxicity_score > threshold:
154
+ print("threshold exceeded!! Launch intervention")
155
  return classify_anxiety
156
 
157
  with gr.Blocks() as iface:
 
160
  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.")
161
  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.")
162
  sense_slider = gr.Slider(minimum=1, maximum=5, step=1.0, label="How readily do you want the tool to intervene? 1 = in extreme cases and 5 = at every opportunity")
163
+ intervention_type = gr.Dropdown(choices=["Audio", "Therapy App", "Text Message"])
164
  with gr.Column():
165
  aud_input = gr.Audio(source="upload", type="filepath", label="Upload Audio File")
166
  text = gr.Textbox(label="Enter Text", placeholder="Enter text here...")
 
169
  out_val = gr.Textbox()
170
  out_class = gr.Textbox()
171
  out_text = gr.Textbox()
172
+ 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, intervention_type])
173
 
174
  iface.launch()