DrishtiSharma commited on
Commit
8314c44
1 Parent(s): 7b9d7c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -15
app.py CHANGED
@@ -21,27 +21,17 @@ asr = pipeline("automatic-speech-recognition", model="jonatasgrosman/wav2vec2-la
21
  def predict_and_ctc_lm_decode(input_file):
22
  speech = load_and_fix_data(input_file, sampling_rate)
23
  transcribed_text = asr(speech, chunk_length_s=5, stride_length_s=1)["text"]
24
- pipe1 = pipeline("sentiment-analysis", model = "finiteautomata/beto-sentiment-analysis")
25
- sentiment = pipe1(transcribed_text)
26
- sentiment={dic["label"]: dic["score"] for dic in sentiment}
27
  pipe2 = pipeline("text-classification", model = "hackathon-pln-es/twitter_sexismo-finetuned-robertuito-exist2021")
28
- sexism_detection = pipe2(transcribed_text)
29
- sexism_detection={dic["label"]: dic["score"] for dic in sexism_detection}
30
- #sexism_detection = np.where(sexism_detection['label']== 0, 'No Sexista', 'Sexista')
31
- pipe3 = pipeline("text-classification", model = "hackathon-pln-es/twitter_sexismo-finetuned-robertuito-exist2021")
32
- harassment_detection = pipe3(transcribed_text)
33
- harassment_detection={dic["label"]: dic["score"] for dic in harassment_detection}
34
- #harassment_detection = np.where(harassment_detection['label']== 0, 'No Harassment', 'Harassment')
35
  return sexism_detection
36
- #sexism_detection, harassment_detection
37
 
38
  gr.Interface(
39
  predict_and_ctc_lm_decode,
40
- inputs=[
41
- gr.inputs.Audio(source="microphone", type="filepath", label="Record your audio")
42
- ],
43
  #outputs=[gr.outputs.Label(num_top_classes=2),gr.outputs.Label(num_top_classes=2), gr.outputs.Label(num_top_classes=2)],
44
- outputs=[gr.outputs.Label(num_top_classes=2)],
45
  examples=[["audio1.wav"], ["audio2.wav"], ["audio3.wav"], ["audio4.wav"], ["sample_audio.wav"]],
46
  title="Spanish-Audio-Transcription-based-Sexism-Detection",
47
  description="This is a Gradio demo for Sentiment Analysis of Transcribed Spanish Audio",
 
21
  def predict_and_ctc_lm_decode(input_file):
22
  speech = load_and_fix_data(input_file, sampling_rate)
23
  transcribed_text = asr(speech, chunk_length_s=5, stride_length_s=1)["text"]
 
 
 
24
  pipe2 = pipeline("text-classification", model = "hackathon-pln-es/twitter_sexismo-finetuned-robertuito-exist2021")
25
+ sexism_detection = pipe2(transcribed_text)[0]['label']
26
+
 
 
 
 
 
27
  return sexism_detection
28
+
29
 
30
  gr.Interface(
31
  predict_and_ctc_lm_decode,
32
+ inputs=[gr.inputs.Audio(source="microphone", type="filepath", label="Record your audio")],
 
 
33
  #outputs=[gr.outputs.Label(num_top_classes=2),gr.outputs.Label(num_top_classes=2), gr.outputs.Label(num_top_classes=2)],
34
+ outputs=[gr.outputs.Textbox(label="Predicción")],
35
  examples=[["audio1.wav"], ["audio2.wav"], ["audio3.wav"], ["audio4.wav"], ["sample_audio.wav"]],
36
  title="Spanish-Audio-Transcription-based-Sexism-Detection",
37
  description="This is a Gradio demo for Sentiment Analysis of Transcribed Spanish Audio",