DrishtiSharma commited on
Commit
3fb5e78
1 Parent(s): ff95de9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -1,18 +1,17 @@
1
-
2
  import gradio as gr
3
  from transformers import pipeline
4
 
5
  #Model_1 = "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD"
6
  #Model_2 ="hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"
7
 
8
- model_name2id = {"Model A": "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD", "Model B": "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"}
9
 
10
- def classify_sentiment(audio, model_name):
11
- pipe = pipeline("audio-classification", model=model_name2id[model_name])
12
  pred = pipe(audio)
13
  return {dic["label"]: dic["score"] for dic in pred}
14
 
15
- input_audio = [gr.inputs.Audio(source="microphone", type="filepath", label="Record/ Drop audio"), gr.inputs.Dropdown([model_name2id["Model A"], model_name2id["Model B"], label="Model Name")]
16
  label = gr.outputs.Label(num_top_classes=5)
17
 
18
  ################### Gradio Web APP ################################
@@ -38,6 +37,5 @@ gr.Interface(
38
  fn = classify_sentiment,
39
  inputs = input_audio,
40
  outputs = label,
41
- examples=[["basta_neutral.wav", model_name2id], ["detras_disgust.wav", model_name2id], ["mortal_sadness.wav", model_name2id], ["respiracion_happiness.wav", model_name2id], ["robo_fear.wav", model_name2id]],
42
  theme="grass").launch()
43
-
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
  #Model_1 = "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD"
5
  #Model_2 ="hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"
6
 
7
+ #model_name2id = {"Model A": "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD", "Model B": "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"}
8
 
9
+ def classify_sentiment(audio):
10
+ pipe = pipeline("audio-classification", model="hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD")
11
  pred = pipe(audio)
12
  return {dic["label"]: dic["score"] for dic in pred}
13
 
14
+ input_audio = [gr.inputs.Audio(source="microphone", type="filepath", label="Record/ Drop audio")]
15
  label = gr.outputs.Label(num_top_classes=5)
16
 
17
  ################### Gradio Web APP ################################
 
37
  fn = classify_sentiment,
38
  inputs = input_audio,
39
  outputs = label,
40
+ examples=[["basta_neutral.wav"], ["detras_disgust.wav"], ["mortal_sadness.wav"], ["respiracion_happiness.wav"], ["robo_fear.wav"]],
41
  theme="grass").launch()