Spaces:
Runtime error
Runtime error
File size: 1,124 Bytes
42a94c6 c8fcb7e 7fb99c3 c8fcb7e 42a94c6 2329fc4 42a94c6 ed34c55 2329fc4 42a94c6 |
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 |
from transformers import pipeline
import gradio as gr
trans = pipeline("automatic-speech-recognition", model ="facebook/wav2vec2-large-xlsr-53-spanish")
traductor = pipeline("translation", model = "Helsinki-NLP/opus-mt-es-en")
ner = pipeline("ner", model = "d4data/biomedical-ner-all")
def audio2text(audio):
text = trans(audio)["text"]
return text
def text2eng(text):
return traductor(text)[0]["translation_text"]
def eng2ner(text):
output = ner(text)
return {"text": text, "entities": output}
demo = gr.Blocks()
with demo:
gr.Markdown("Demo sobre historia clínica en español a entidades en ingles")
audio = gr.Audio(sources="microphone", type="filepath")
b_text = gr.Button("Transcribir")
texto = gr.Textbox()
b_text.click(audio2text, inputs=audio, outputs=texto)
b_trans = gr.Button("Traducir historia")
transcripcion = gr.Textbox()
b_trans.click(text2eng, inputs=texto, outputs=transcripcion)
b_ner =gr.Button("Search entities")
entidades = gr.HighlightedText()
b_ner.click(eng2ner, inputs=transcripcion, outputs=entidades)
demo.launch() |