Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
trans = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-xlsr-53-spanish")
|
| 5 |
+
clasificador = pipeline("text-classification", model="pysentimiento/robertuito-sentiment-analysis")
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def audio_a_text (audio):
|
| 9 |
+
text = trans(audio)["text"]
|
| 10 |
+
return text
|
| 11 |
+
|
| 12 |
+
def texto_a_sentimiento (text):
|
| 13 |
+
return clasificador (text)[0]["label"]
|
| 14 |
+
|
| 15 |
+
demo = gr.Blocks()
|
| 16 |
+
|
| 17 |
+
with demo:
|
| 18 |
+
gr.Markdown("Demo para la Clase de Platzi")
|
| 19 |
+
audio = gr.Audio (source="microphone",type="filepath")
|
| 20 |
+
texto = gr.Texbox()
|
| 21 |
+
b1=gr.Button("Transcribe porfa")
|
| 22 |
+
b1.click(audio_a_text, inputs=audio, outputs=texto)
|
| 23 |
+
|
| 24 |
+
label = gr.label()
|
| 25 |
+
b2 =gr.Button("Clasifica porfa el sentimiento")
|
| 26 |
+
b2.click(texto_a_sentimiento, inputs=texto, outputs=label)
|
| 27 |
+
|
| 28 |
+
demo.launch()
|
| 29 |
+
|