amannnnn commited on
Commit
e7390df
·
verified ·
1 Parent(s): 21a6582

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -4
app.py CHANGED
@@ -1,7 +1,30 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import RobertaTokenizerFast, TFRobertaForSequenceClassification, pipeline
3
+ import whisper
4
 
5
+ model = whisper.load_model('base')
 
6
 
7
+ tokenizer = RobertaTokenizerFast.from_pretrained("arpanghoshal/EmoRoBERTa")
8
+ model2 = TFRobertaForSequenceClassification.from_pretrained("arpanghoshal/EmoRoBERTa")
9
+
10
+ emotion = pipeline('sentiment-analysis', model='arpanghoshal/EmoRoBERTa')
11
+
12
+ classifier = pipeline(task="text-classification", model="SamLowe/roberta-base-go_emotions", top_k=None)
13
+
14
+ input_audio = gr.Audio(sources=['microphone','upload'], label='Speak with me...', show_label=True, interactive=True, format=['wav'])
15
+
16
+ def voice_to_emotion(audio):
17
+ result = model.transcribe(audio, fp16 = False)
18
+ txt = result['text']
19
+ model_outputs = classifier(txt)
20
+ res = ''
21
+ for each in model_outputs[0]:
22
+ res = str(each['label'])
23
+ return res
24
+
25
+ demo = gr.Interface(
26
+ fn=voice_to_emotion,
27
+ inputs = input_audio,
28
+ outputs = "textbox")
29
+
30
+ demo.launch()