KG0101 commited on
Commit
5320fa6
1 Parent(s): b39f388

Update to separate outputs

Browse files
Files changed (1) hide show
  1. app.py +32 -29
app.py CHANGED
@@ -89,42 +89,45 @@ def generate_soap(
89
  outputs.append(text)
90
  yield "".join(outputs)
91
 
92
- # Combine transcription and SOAP generation
93
- def transcribe_and_generate_soap(audio, task, system_prompt, max_new_tokens, temperature, top_p, top_k, repetition_penalty):
94
- # First transcribe the audio
95
- transcribed_text = transcribe(audio, task)
96
- # Then generate SOAP notes based on the transcription and collect all generated text into a single string
97
- generated_text = "".join(generate_soap(
98
- transcribed_text,
99
- system_prompt,
100
- max_new_tokens,
101
- temperature,
102
- top_p,
103
- top_k,
104
- repetition_penalty
105
- ))
106
- return generated_text
107
-
108
  # Gradio Interface combining transcription and SOAP note generation
109
  demo = gr.Blocks(theme=gr.themes.Ocean())
110
 
111
  with demo:
112
  with gr.Tab("Clinical SOAP Note from Audio"):
113
- audio_transcribe_and_soap = gr.Interface(
114
- fn=transcribe_and_generate_soap,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  inputs=[
116
- gr.Audio(sources=["microphone", "upload"], type="filepath", label="Audio Input"),
117
- gr.Radio(["transcribe", "translate"], label="Task", value="transcribe"),
118
- gr.Textbox(label="System Prompt", lines=2, value="You are a world class clinical assistant."),
119
- gr.Slider(label="Max new tokens", minimum=1, maximum=2048, value=1024, step=1),
120
- gr.Slider(label="Temperature", minimum=0.1, maximum=4.0, value=0.6, step=0.1),
121
- gr.Slider(label="Top-p", minimum=0.05, maximum=1.0, value=0.9, step=0.05),
122
- gr.Slider(label="Top-k", minimum=1, maximum=1000, value=50, step=1),
123
- gr.Slider(label="Repetition penalty", minimum=1.0, maximum=2.0, value=1.2, step=0.05)
124
  ],
125
- outputs="text",
126
- title="Generate Clinical SOAP Note from Audio",
127
- description="Transcribe audio input and convert it into a structured clinical SOAP note."
128
  )
129
 
130
  demo.queue().launch(ssr_mode=False)
 
89
  outputs.append(text)
90
  yield "".join(outputs)
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  # Gradio Interface combining transcription and SOAP note generation
93
  demo = gr.Blocks(theme=gr.themes.Ocean())
94
 
95
  with demo:
96
  with gr.Tab("Clinical SOAP Note from Audio"):
97
+ # Transcription Interface
98
+ audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath", label="Audio Input")
99
+ task_input = gr.Radio(["transcribe", "translate"], label="Task", value="transcribe")
100
+ transcription_output = gr.Textbox(label="Transcription Output")
101
+
102
+ # Transcription button
103
+ transcribe_button = gr.Button("Transcribe")
104
+ transcribe_button.click(fn=transcribe, inputs=[audio_input, task_input], outputs=transcription_output)
105
+
106
+ # SOAP Generation Interface
107
+ transcribed_text_input = gr.Textbox(label="Edit Transcription before SOAP Generation", lines=5)
108
+ system_prompt_input = gr.Textbox(label="System Prompt", lines=2, value="You are a world class clinical assistant.")
109
+ max_new_tokens_input = gr.Slider(label="Max new tokens", minimum=1, maximum=2048, value=1024, step=1)
110
+ temperature_input = gr.Slider(label="Temperature", minimum=0.1, maximum=4.0, value=0.6, step=0.1)
111
+ top_p_input = gr.Slider(label="Top-p", minimum=0.05, maximum=1.0, value=0.9, step=0.05)
112
+ top_k_input = gr.Slider(label="Top-k", minimum=1, maximum=1000, value=50, step=1)
113
+ repetition_penalty_input = gr.Slider(label="Repetition penalty", minimum=1.0, maximum=2.0, value=1.2, step=0.05)
114
+
115
+ soap_output = gr.Textbox(label="Generated SOAP Note Output")
116
+
117
+ # SOAP generation button
118
+ generate_soap_button = gr.Button("Generate SOAP Note")
119
+ generate_soap_button.click(
120
+ fn=generate_soap,
121
  inputs=[
122
+ transcribed_text_input,
123
+ system_prompt_input,
124
+ max_new_tokens_input,
125
+ temperature_input,
126
+ top_p_input,
127
+ top_k_input,
128
+ repetition_penalty_input
 
129
  ],
130
+ outputs=soap_output
 
 
131
  )
132
 
133
  demo.queue().launch(ssr_mode=False)