Spaces:
Sleeping
Sleeping
File size: 1,760 Bytes
3ec6b68 49efc90 3ec6b68 61c4a9f 49efc90 85984b8 c261516 3ec6b68 49efc90 3ec6b68 49efc90 c261516 49efc90 c261516 49efc90 3ec6b68 49efc90 85984b8 49efc90 3ec6b68 49efc90 3ec6b68 49efc90 3ec6b68 49efc90 3ec6b68 49efc90 abc07cc bd3983e 76de0a0 abc07cc 3ec6b68 2c03d43 49efc90 a0f6f3c 49efc90 |
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 |
import gradio as gr
from transformers import pipeline
import torch
modelo_path = "proxectonos/Nos_ASR-wav2vec2-large-xlsr-53-gl-with-lm"
asr_pipeline = pipeline(
"automatic-speech-recognition",
model=modelo_path,
device=0 if torch.cuda.is_available() else -1
)
fronted_theme = "Soft"
def cargar(audio_filepath):
if audio_filepath is None:
return "Por favor, carga un ficheiro de audio."
outtext = asr_pipeline(audio_filepath)
texto_transcrito = outtext["text"]
return texto_transcrito
with gr.Blocks(fronted_theme) 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],
)
demo.launch() |