Spaces:
Runtime error
Runtime error
Commit
Β·
8b4c65a
1
Parent(s):
22b71df
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
|
|
1 |
import os
|
2 |
import numpy as np
|
3 |
import gradio as gr
|
4 |
from gradio.mix import Series
|
5 |
-
from transformers import pipeline
|
6 |
|
7 |
path_to_L_model = str(os.environ['path_to_L_model'])
|
8 |
read_token = str(os.environ['read_token'])
|
@@ -10,46 +10,17 @@ read_token = str(os.environ['read_token'])
|
|
10 |
description = "Talk to Breud!"
|
11 |
title = "Breud (BERT + Freud)"
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
# interface_model_L = gr.Interface.load(
|
16 |
-
# name=path_to_L_model,
|
17 |
-
# api_key=read_token,
|
18 |
-
# )
|
19 |
-
|
20 |
-
# Series(
|
21 |
-
# wisper,
|
22 |
-
# interface_model_L,
|
23 |
-
# description = description,
|
24 |
-
# title = title,
|
25 |
-
# inputs = gr.Audio(source="microphone"),
|
26 |
-
# ).launch()
|
27 |
-
|
28 |
-
|
29 |
-
asr = pipeline("automatic-speech-recognition", "openai/whisper-base")
|
30 |
-
classifier = pipeline("text-classification", path_to_L_model, api_token=read_token)
|
31 |
-
|
32 |
-
|
33 |
-
def speech_to_text(speech):
|
34 |
-
text = asr(speech)["text"]
|
35 |
-
return text
|
36 |
-
|
37 |
-
|
38 |
-
def text_to_sentiment(text):
|
39 |
-
return classifier(text)[0]["label"]
|
40 |
-
|
41 |
-
|
42 |
-
demo = gr.Blocks()
|
43 |
-
|
44 |
-
with demo:
|
45 |
-
audio_file = gr.Audio(source="microphone")
|
46 |
-
text = gr.Textbox()
|
47 |
-
label = gr.Label()
|
48 |
-
|
49 |
-
b1 = gr.Button("Recognize Speech")
|
50 |
-
b2 = gr.Button("Classify Sentiment")
|
51 |
|
52 |
-
|
53 |
-
|
|
|
|
|
54 |
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
import os
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
5 |
from gradio.mix import Series
|
|
|
6 |
|
7 |
path_to_L_model = str(os.environ['path_to_L_model'])
|
8 |
read_token = str(os.environ['read_token'])
|
|
|
10 |
description = "Talk to Breud!"
|
11 |
title = "Breud (BERT + Freud)"
|
12 |
|
13 |
+
wisper = gr.Interface.load("models/openai/whisper-base")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
interface_model_L = gr.Interface.load(
|
16 |
+
name=path_to_L_model,
|
17 |
+
api_key=read_token,
|
18 |
+
)
|
19 |
|
20 |
+
Series(
|
21 |
+
wisper,
|
22 |
+
interface_model_L,
|
23 |
+
description = description,
|
24 |
+
title = title,
|
25 |
+
inputs = gr.Audio(source="microphone"),
|
26 |
+
).launch()
|