-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.py
More file actions
40 lines (32 loc) · 1.24 KB
/
interface.py
File metadata and controls
40 lines (32 loc) · 1.24 KB
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
import gradio as gr
def run_interface(transcribe, predict_icd) -> None:
"""Run the Gradio interface for audio transcription and ICD-10 code prediction."""
with gr.Blocks() as demo:
with gr.Row(equal_height=True):
# Audio input and transcription
with gr.Column():
audio_input = gr.Audio(type="filepath", label="Upload or record audio")
transcribe_btn = gr.Button("Transcribe")
# ICD-10 code prediction
with gr.Column():
transcribed_text = gr.Textbox(
label="Transcribed", interactive=True
) # Now editable!
icd_btn = gr.Button("Get ICD-10 Codes")
# Display ICD-10 codes
with gr.Column():
icd10_codes = gr.Markdown(label="ICD-10 Code(s)")
# CALLBACK FUNCTIONS
# Button for transcription
transcribe_btn.click(
fn=transcribe,
inputs=[audio_input],
outputs=[transcribed_text],
)
# Button for ICD-10 prediction
icd_btn.click(
fn=predict_icd,
inputs=[transcribed_text],
outputs=[icd10_codes],
)
demo.launch(debug=False, share=False)