Update app.py
Browse files
app.py
CHANGED
|
@@ -49,28 +49,28 @@ def transcribe(audio, history_type):
|
|
| 49 |
|
| 50 |
|
| 51 |
######################## Take Audio from Numpy Array
|
| 52 |
-
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
######################## Read audio file, if using file
|
| 57 |
-
max_attempts = 1
|
| 58 |
-
attempt = 0
|
| 59 |
-
audio_data = None
|
| 60 |
-
samplerate = None
|
| 61 |
-
while attempt < max_attempts:
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
else:
|
| 72 |
-
|
| 73 |
-
|
| 74 |
|
| 75 |
|
| 76 |
########## Cast as float 32, normalize
|
|
@@ -133,8 +133,8 @@ def transcribe(audio, history_type):
|
|
| 133 |
#Define Gradio Interface
|
| 134 |
my_inputs = [
|
| 135 |
#gr.Audio(source="microphone", type="filepath"), #Gradio 3.48.0
|
| 136 |
-
gr.Audio(sources=["microphone"], type="filepath",format="wav"), #Gradio 4.x
|
| 137 |
-
|
| 138 |
gr.Radio(["History","H+P","Impression/Plan","Full Visit","Handover","Psych","EMS","SBAR","Meds Only"], show_label=False),
|
| 139 |
]
|
| 140 |
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
######################## Take Audio from Numpy Array
|
| 52 |
+
samplerate, audio_data = audio
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
######################## Read audio file, if using file
|
| 57 |
+
#max_attempts = 1
|
| 58 |
+
#attempt = 0
|
| 59 |
+
#audio_data = None
|
| 60 |
+
#samplerate = None
|
| 61 |
+
#while attempt < max_attempts:
|
| 62 |
+
# try:
|
| 63 |
+
# if audio is None:
|
| 64 |
+
# raise TypeError("Invalid file: None")
|
| 65 |
+
# audio_data, samplerate = sf.read(audio)
|
| 66 |
+
# break
|
| 67 |
+
# except (OSError, TypeError) as e:
|
| 68 |
+
# print(f"Attempt {attempt + 1} of {max_attempts} failed with error: {e}")
|
| 69 |
+
# attempt += 1
|
| 70 |
+
# time.sleep(3)
|
| 71 |
+
#else:
|
| 72 |
+
# print(f"###############Failed to open audio file after {max_attempts} attempts.##############")
|
| 73 |
+
# return # Terminate the function or raise an exception if the file could not be opened
|
| 74 |
|
| 75 |
|
| 76 |
########## Cast as float 32, normalize
|
|
|
|
| 133 |
#Define Gradio Interface
|
| 134 |
my_inputs = [
|
| 135 |
#gr.Audio(source="microphone", type="filepath"), #Gradio 3.48.0
|
| 136 |
+
#gr.Audio(sources=["microphone"], type="filepath",format="wav"), #Gradio 4.x
|
| 137 |
+
gr.Audio(sources=["microphone"],type="numpy"), #Gradio 4.x
|
| 138 |
gr.Radio(["History","H+P","Impression/Plan","Full Visit","Handover","Psych","EMS","SBAR","Meds Only"], show_label=False),
|
| 139 |
]
|
| 140 |
|