File size: 2,073 Bytes
93d7c3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import torch 
import spacy
import os
import whisper
os.system('pip install https://huggingface.co/Armandoliv/es_pipeline/resolve/main/es_pipeline-any-py3-none-any.whl')
os.system('pip install git+https://github.com/openai/whisper.git')

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")


nlp_ner = spacy.load("es_pipeline")

def main_generator(youtube_id:str):
  YouTubeID = youtube_id # ¿Qué es la enfermedad de Crohn y cómo detectarla?
  OutputFile = 'test_audio_youtube_.m4a'

  os.system(f"youtube-dl -o {OutputFile} {YouTubeID} --extract-audio --restrict-filenames -f 'bestaudio[ext=m4a]'")
  model_whisper = whisper.load_model("small")
  result = model_whisper.transcribe(OutputFile)
  text = result['text']
  output_list = []
  for ent in doc.ents:
      result_dict = {
          'entity': ent.label_,
          'word': ent.text,
          'start':ent.start_char,
          'end': ent.end_char
      }
      output_list.append(result_dict)

  return {"text": text, "entities": output_list}      
inputs = [gr.Textbox(lines=1, placeholder="Link of youtube video here...", label="Input")]
outputs = gr.HighlightedText()
title="ASR FOR MEDICAL RECORDS"
description = "This demo uses AI Models to create an AUDIO ANNOTATION FOR MEDICAL RECORDS"
examples = ['xOZM-1p-jAk']

io = gr.Interface(fn=main_generator, inputs=inputs, outputs=outputs, title=title, description = description, examples = examples,

                  css= """.gr-button-primary { background: -webkit-linear-gradient( 
                    90deg, #355764 0%, #55a8a1 100% ) !important;     background: #355764;
                        background: linear-gradient( 
                    90deg, #355764 0%, #55a8a1 100% ) !important;
                        background: -moz-linear-gradient( 90deg, #355764 0%, #55a8a1 100% ) !important;
                        background: -webkit-linear-gradient( 
                    90deg, #355764 0%, #55a8a1 100% ) !important;
                    color:white !important}"""
                  )
  
io.launch(debug=True)