Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|