File size: 1,411 Bytes
2d38fb9
dc14bee
 
 
 
 
 
e6e6350
dc14bee
 
 
 
 
3a7c2ae
999c59d
dc14bee
34321c5
 
 
 
 
3da0176
34321c5
 
 
 
3da0176
34321c5
 
 
 
 
3da0176
 
34321c5
3a7c2ae
dc14bee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import gradio as gr
from transformers import pipeline

transcripcion = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-xlsr-53-spanish")
clasificador = pipeline("text-classification", model="pysentimiento/robertuito-sentiment-analysis")
def audio_a_texto(audio):
  texto = transcripcion(audio)["text"]
  return texto, texto

def texto_a_sentimiento(texto):
  sentimiento = clasificador(texto)[0]["label"]
  return sentimiento
demo = gr.Blocks()

    
with demo:
    gr.Markdown("## Transcribe audio2text and sentimental classification - Spanish")
    with gr.Tabs():
        with gr.TabItem("Transcribe"):
            with gr.Row():
                audio_input = gr.Audio(sources=["microphone"], type="filepath")
                texto_output = gr.Textbox(label="Audio to text")
            with gr.Row():
                b1 = gr.Button("Transcribe 🎙️✍🏻")
        with gr.TabItem("Sentimental Classification"):
            with gr.Row():
                texto_input = gr.Textbox(label="Text to sentimental")
                sentimiento_output = gr.Label()
            with gr.Row():
                b2 = gr.Button("Sentimental Classification 🤖")

    # Keep the 2 text box with the same text.

    b1.click(audio_a_texto, inputs=audio_input, outputs=[texto_output,texto_input])
    b2.click(texto_a_sentimiento, inputs=texto_input, outputs=sentimiento_output)

demo.launch()