Jesse Liu commited on
Commit
7d375b1
·
1 Parent(s): ce10534

Sync latest app + data (clinician groups, jsonl)

Browse files
Files changed (1) hide show
  1. chatgpt.py +14 -2
chatgpt.py CHANGED
@@ -1,5 +1,4 @@
1
  import gradio as gr
2
- import whisper
3
  import asyncio
4
  import httpx
5
  import tempfile
@@ -23,6 +22,14 @@ except ImportError:
23
  import shutil
24
  import zipfile
25
 
 
 
 
 
 
 
 
 
26
  # ICD-10 code to description mapping (common codes)
27
  ICD10_DESCRIPTIONS = {
28
  "I130": "Hypertensive heart and chronic kidney disease",
@@ -84,7 +91,10 @@ LAB_TEST_NAMES = {
84
 
85
  session = requests.Session()
86
 
87
- model = whisper.load_model("base")
 
 
 
88
 
89
  base_url = "http://localhost:8080"
90
 
@@ -251,6 +261,8 @@ def download_conversations(username, chatbot_type):
251
  # return temp_file_path, gr.update(value=biography_text, visible=True)
252
 
253
  def transcribe_audio(audio_file):
 
 
254
  transcription = model.transcribe(audio_file)["text"]
255
  return transcription
256
 
 
1
  import gradio as gr
 
2
  import asyncio
3
  import httpx
4
  import tempfile
 
22
  import shutil
23
  import zipfile
24
 
25
+ # Optional Whisper ASR support (for local use); not required on Hugging Face Space
26
+ try:
27
+ import whisper # type: ignore
28
+ WHISPER_AVAILABLE = True
29
+ except ImportError:
30
+ whisper = None # type: ignore
31
+ WHISPER_AVAILABLE = False
32
+
33
  # ICD-10 code to description mapping (common codes)
34
  ICD10_DESCRIPTIONS = {
35
  "I130": "Hypertensive heart and chronic kidney disease",
 
91
 
92
  session = requests.Session()
93
 
94
+ if WHISPER_AVAILABLE:
95
+ model = whisper.load_model("base")
96
+ else:
97
+ model = None
98
 
99
  base_url = "http://localhost:8080"
100
 
 
261
  # return temp_file_path, gr.update(value=biography_text, visible=True)
262
 
263
  def transcribe_audio(audio_file):
264
+ if not WHISPER_AVAILABLE or model is None:
265
+ raise RuntimeError("Audio transcription model is not available in this deployment.")
266
  transcription = model.transcribe(audio_file)["text"]
267
  return transcription
268