File size: 1,225 Bytes
b5dcfd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from huggingsound import SpeechRecognitionModel
import gradio as gr


model = SpeechRecognitionModel("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm")


def transcribe(audio, state=""):    
    transcriptions_es = model.transcribe([audio])[0]    
    # Algoritmo here

    recomendacion = "definir variable"
    return transcriptions_es['transcription'], recomendacion

inputs = gr.inputs.Audio(label="Dar click para escuchar tu voz", type="filepath", source="microphone")
output1 = gr.outputs.Textbox(label="Asi se ve tu c贸digo")
output2 = gr.outputs.Textbox(label="Tal vez quisiste decir:")

title = "Expresate con voz"
description = "Aplicaci贸n que ayuda a programar a traves de tu voz"
examples = ['definir funci贸n', 'definir variable', 'definir clase']
article = "<a  style='color:#eb9f59;' href = 'https://github.com/gandres-dev/Hackaton-Common-Voice'> Repositorio de la app"
demo = gr.Interface(fn=transcribe, inputs=inputs, outputs=[output1,output2],
                    title=title, description=description, article=article,
                    allow_flagging="never", theme="darkpeach", examples=examples,
                    live=True
                    )

if __name__ == "__main__":
    demo.launch()