File size: 2,217 Bytes
3ec6b68
 
 
 
85984b8
c261516
3ec6b68
 
 
 
 
 
c261516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ec6b68
 
 
85984b8
 
 
 
 
 
 
 
3ec6b68
 
 
 
85984b8
 
 
 
 
3ec6b68
85984b8
 
 
3ec6b68
 
 
 
abc07cc
bd3983e
76de0a0
abc07cc
3ec6b68
 
 
 
 
 
 
 
 
 
 
a0f6f3c
 
2c03d43
 
a0f6f3c
 
3ec6b68
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import gradio as gr

modelo_path = "models/proxectonos/Nos_ASR-wav2vec2-large-xlsr-53-gl-with-lm"
modelo = gr.load(modelo_path)

fronted_theme = "Soft"

def cargar(audio):   
    outtext = modelo(audio)
    texto_transcrito = outtext.split("'")[1].strip()
    return texto_transcrito

custom_css = """
#send-btn {
    background-color: blue;
    color: white;
}
#clear-btn {
    background-color: green;
    color: white; 
}
#send-btn:hover {
    box-shadow: 3px 3px 5px #0056b3;
}
#clear-btn:hover {
    box-shadow: 3px 3px 5px #1e7e34;
}

"""

with gr.Blocks(fronted_theme, css=custom_css) as demo:
    with gr.Row():
        with gr.Column():
            gr.Markdown(
                """
                ## <h1 style="text-align:center">🗣️📄 ASR Demo Proxecto Nós </h1>
                """
            )
            gr.Markdown(
                """
                ## <img src="https://huggingface.co/spaces/proxectonos/README/resolve/main/title-card.png" width="100%" style="border-radius: 0.75rem;">
                """
            )
        with gr.Column():
            with gr.Row():            
                gr.Markdown(
                    """
                    <br/>
                    <br/>
                    <br/>
                    <br/>
                
                    💻 Este space mostra o modelo ASR desenvolvido polo **[Proxecto Nós](https://huggingface.co/proxectonos)**.
                    <br/>
                    """
                )
            with gr.Row():            
                input_audio = gr.Audio(label="Entrada", type="filepath")
            with gr.Row():            
                output_text = gr.Textbox(label="Saída", type="text")
            with gr.Row():
                asr_button = gr.Button("Xerar", elem_id="send-btn", visible=True)
                clear_button = gr.ClearButton([input_audio, output_text], value="Limpar", elem_id="clear-btn", visible=True)


    asr_button.click(
        cargar,
        inputs=[
            input_audio,
        ],
        outputs=[output_text],
        
    )

    examples = gr.Examples(
        ["Celtia1.wav"],
        inputs=[input_audio],
        label="Exemplo"
    )

demo.launch(debug=True)