Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,13 @@
|
|
| 1 |
-
from transformers import pipeline
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
def text_to_sentiment(text):
|
| 15 |
-
return classifier(text)[0]["label"]
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
demo = gr.Blocks()
|
| 19 |
-
|
| 20 |
-
with demo:
|
| 21 |
-
audio_file = gr.Audio(type="filepath")
|
| 22 |
-
text = gr.Textbox()
|
| 23 |
-
label = gr.Label()
|
| 24 |
-
|
| 25 |
-
b1 = gr.Button("Recognize Speech")
|
| 26 |
-
b2 = gr.Button("Classify Sentiment")
|
| 27 |
-
|
| 28 |
-
b1.click(speech_to_text, inputs=audio_file, outputs=text)
|
| 29 |
-
b2.click(text_to_sentiment, inputs=text, outputs=label)
|
| 30 |
|
| 31 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
def update(name):
|
| 3 |
+
return f"Welcome to Gradio, {name}!"
|
| 4 |
+
|
| 5 |
+
with gr.Blocks() as demo:
|
| 6 |
+
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
| 7 |
+
with gr.Row():
|
| 8 |
+
inp = gr.Textbox(placeholder="What is your name?")
|
| 9 |
+
out = gr.Textbox()
|
| 10 |
+
btn = gr.Button("Run")
|
| 11 |
+
btn.click(fn=update, inputs=inp, outputs=out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
demo.launch()
|