File size: 1,836 Bytes
534e084
d8215b2
96bde30
fff86d3
52bf87c
d8215b2
 
 
96bde30
 
 
 
52bf87c
9679b96
606f31e
 
7624a50
606f31e
7624a50
fff86d3
4f54e11
2428837
fff86d3
 
 
 
71cdb69
fff86d3
3313eeb
 
 
96bde30
3313eeb
71cdb69
 
fff86d3
 
9679b96
96bde30
 
 
 
 
26cc76d
 
 
 
71cdb69
96bde30
 
71cdb69
3313eeb
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 pydub import AudioSegment
from ailib import whisper_transcribe, summarize
import pandas as pd

def transcribe(audiofile):
    #audio = AudioSegment.from_file(audiofile)
    #open(filename, 'wb').write(audio)
    consulta = whisper_transcribe(audiofile)
    resumen = summarize(consulta)
    random = 'CHALLA!'
    return consulta, resumen, random

def display_text(paciente):
    resumen_historial = df[df.paciente==paciente]['Resumen'].iloc[0]
    historial = df[df.paciente==paciente]['EHR'].iloc[0]    
    
    return resumen_historial, historial

df = pd.read_csv('pacientes.csv')
pacientes = list(df['paciente'].unique())             # now contains PAC_ID
print('PAX:', pacientes, type(pacientes))
pid_dict = dict(zip(df.paciente, df.pac_id))
################################################
# gr.title("Demo CORFO")

with gr.Blocks() as demo:
    with gr.Row():     
        audemo = gr.Interface(
            transcribe,
            gr.Audio(sources=["microphone"], type="filepath"),
            ["text","text","text"]   # was simply "text",
        )
    with gr.Row():
        with gr.Column(scale=1):
            radio = gr.Radio(choices=pacientes, 
                             label="PACIENTE", value=pacientes[0], interactive=True)
        with gr.Column(scale=4):
            with gr.Row():   # historial+resumen
                resumen_trans = gr.Markdown()
                nueva_ficha = gr.Markdown()
                
            with gr.Row():   # historial+resumen
                with gr.Accordion('Resumen Historial'):   # use radio?
                    left_text = gr.Markdown()
                with gr.Accordion('Historial'):
                    right_text = gr.Markdown()
    
    radio.change(display_text, inputs=radio, 
                 outputs=[left_text, right_text])

demo.launch()