majweldon commited on
Commit
38eff04
·
verified ·
1 Parent(s): f302609

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -49,28 +49,28 @@ def transcribe(audio, history_type):
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,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
- #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
 
 
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