Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -132,6 +132,21 @@ def new_func(user_window):
|
|
132 |
dataFile = dataDir + user_window + '_log.txt'
|
133 |
return dataFile
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
with gr.Blocks() as demo:
|
136 |
history = gr.State([])
|
137 |
password = gr.State("")
|
@@ -143,6 +158,10 @@ with gr.Blocks() as demo:
|
|
143 |
user_window = gr.Textbox(label = "User Name")
|
144 |
pwd_window = gr.Textbox(label = "Password")
|
145 |
pwd_window.blur(updatePassword, pwd_window, [password, pwd_window])
|
|
|
|
|
|
|
|
|
146 |
with gr.Row():
|
147 |
clear_button = gr.Button(value="Restart Conversation")
|
148 |
# gpt_chooser=gr.Radio(choices=[("GPT-3.5","gpt-3.5-turbo"),("GPT-4o","gpt-4o-mini")],
|
@@ -153,5 +172,7 @@ with gr.Blocks() as demo:
|
|
153 |
submit_window.click(chat, inputs=[prompt_window, user_window, password, history, output_window, model],
|
154 |
outputs=[history, output_window, prompt_window, model])
|
155 |
clear_button.click(clear, inputs=[], outputs=[prompt_window, history, output_window])
|
156 |
-
|
157 |
-
|
|
|
|
|
|
132 |
dataFile = dataDir + user_window + '_log.txt'
|
133 |
return dataFile
|
134 |
|
135 |
+
def new_func1():
|
136 |
+
reset_button = gr.ClearButton(value="Reset Voice Entry", scale=1)
|
137 |
+
return reset_button
|
138 |
+
|
139 |
+
def transcribe(user, pwd, fpath):
|
140 |
+
user = user.lower().strip()
|
141 |
+
pwd = pwd.lower().strip()
|
142 |
+
if not (user in unames and pwd in pwdList):
|
143 |
+
return 'Bad credentials'
|
144 |
+
with open(fpath,'rb') as audio_file:
|
145 |
+
transcript = client.audio.transcriptions.create(
|
146 |
+
model='whisper-1', file = audio_file ,response_format = 'text' )
|
147 |
+
reply = transcript
|
148 |
+
return str(reply)
|
149 |
+
|
150 |
with gr.Blocks() as demo:
|
151 |
history = gr.State([])
|
152 |
password = gr.State("")
|
|
|
158 |
user_window = gr.Textbox(label = "User Name")
|
159 |
pwd_window = gr.Textbox(label = "Password")
|
160 |
pwd_window.blur(updatePassword, pwd_window, [password, pwd_window])
|
161 |
+
with gr.Row():
|
162 |
+
audio_widget = gr.Audio(type='filepath', format='wav',waveform_options=gr.WaveformOptions(
|
163 |
+
show_recording_waveform=True), sources=['microphone'], scale = 3, label="Prompt/Question Voice Entry", max_length=40)
|
164 |
+
reset_button = new_func1()
|
165 |
with gr.Row():
|
166 |
clear_button = gr.Button(value="Restart Conversation")
|
167 |
# gpt_chooser=gr.Radio(choices=[("GPT-3.5","gpt-3.5-turbo"),("GPT-4o","gpt-4o-mini")],
|
|
|
172 |
submit_window.click(chat, inputs=[prompt_window, user_window, password, history, output_window, model],
|
173 |
outputs=[history, output_window, prompt_window, model])
|
174 |
clear_button.click(clear, inputs=[], outputs=[prompt_window, history, output_window])
|
175 |
+
audio_widget.stop_recording(fn=transcribe, inputs=[user_window, password, audio_widget],
|
176 |
+
outputs=[prompt_window])
|
177 |
+
reset_button.add(audio_widget)
|
178 |
+
demo.launch(share=True)
|