Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -222,7 +222,7 @@ def pred(user_name, image_path, audio, user_input):
|
|
222 |
res = output["description"]
|
223 |
with open(input_filepath, 'w') as f:
|
224 |
f.write("Studs Terkel: " + res)
|
225 |
-
return None, "", "" , res, transform_text_to_speech(res, user_name)
|
226 |
|
227 |
else:
|
228 |
|
@@ -270,6 +270,9 @@ def pred(user_name, image_path, audio, user_input):
|
|
270 |
|
271 |
# Backend function to clear inputs
|
272 |
def clear_inputs(user_name, image_path):
|
|
|
|
|
|
|
273 |
image_name = image_path.split("/")[-1]
|
274 |
input_filename = f"{user_name}-{image_name}-conversation-memory.txt"
|
275 |
input_filepath = f"/data/conversations/{input_filename}"
|
@@ -277,7 +280,7 @@ def clear_inputs(user_name, image_path):
|
|
277 |
with open(input_filepath, 'a') as f:
|
278 |
f.write("\n" + f"{user_name}: " + "new photo uploaded")
|
279 |
|
280 |
-
return None, None, "", "", "Please
|
281 |
|
282 |
# Gradio Interface
|
283 |
with gr.Blocks() as demo:
|
@@ -302,7 +305,7 @@ with gr.Blocks() as demo:
|
|
302 |
|
303 |
# Linking the submit button with the save_audio function
|
304 |
submit_button.click(fn=pred, inputs=[username, image_input, audio_input, text_input],
|
305 |
-
outputs=[audio_input, text_input, user_input_output, stud_output, audio_output
|
306 |
|
307 |
# Linking the clear button with the clear_inputs function
|
308 |
clear_button.click(fn=clear_inputs, inputs=[username, image_input], outputs=[image_input, audio_input, text_input, user_input_output, stud_output, audio_output])
|
|
|
222 |
res = output["description"]
|
223 |
with open(input_filepath, 'w') as f:
|
224 |
f.write("Studs Terkel: " + res)
|
225 |
+
return None, "", "New Photo Uploaded" , res, transform_text_to_speech(res, user_name)
|
226 |
|
227 |
else:
|
228 |
|
|
|
270 |
|
271 |
# Backend function to clear inputs
|
272 |
def clear_inputs(user_name, image_path):
|
273 |
+
if user_name.strip() == "" or image_path == None:
|
274 |
+
return None, None, "", "", "Please upload a new photo", transform_text_to_speech("Please upload a new photo", user_name)
|
275 |
+
|
276 |
image_name = image_path.split("/")[-1]
|
277 |
input_filename = f"{user_name}-{image_name}-conversation-memory.txt"
|
278 |
input_filepath = f"/data/conversations/{input_filename}"
|
|
|
280 |
with open(input_filepath, 'a') as f:
|
281 |
f.write("\n" + f"{user_name}: " + "new photo uploaded")
|
282 |
|
283 |
+
return None, None, "", "", "Please upload a new photo", transform_text_to_speech("Please upload a new photo", user_name)
|
284 |
|
285 |
# Gradio Interface
|
286 |
with gr.Blocks() as demo:
|
|
|
305 |
|
306 |
# Linking the submit button with the save_audio function
|
307 |
submit_button.click(fn=pred, inputs=[username, image_input, audio_input, text_input],
|
308 |
+
outputs=[audio_input, text_input, user_input_output, stud_output, audio_output])
|
309 |
|
310 |
# Linking the clear button with the clear_inputs function
|
311 |
clear_button.click(fn=clear_inputs, inputs=[username, image_input], outputs=[image_input, audio_input, text_input, user_input_output, stud_output, audio_output])
|