samir72 commited on
Commit
c96bf89
·
1 Parent(s): 67af8a0

Add Logging

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -55,7 +55,7 @@ def summarize_audio_b64(audio_b64: str, sys_prompt: str, user_prompt: str) -> st
55
  return response.choices[0].message.content
56
 
57
  except Exception as ex:
58
- return f"Error from Azure OpenAI: {ex}"
59
 
60
 
61
  # --- I/O helpers ------------------------------------------------------------
@@ -93,6 +93,10 @@ def process_audio(upload_path, record_path, url, sys_prompt, user_prompt):
93
  audio_b64 = encode_audio_from_path(audio_path)
94
  return summarize_audio_b64(audio_b64, sys_prompt, user_prompt)
95
 
 
 
 
 
96
  finally:
97
  for p in tmp_to_cleanup:
98
  try:
@@ -130,6 +134,26 @@ with gr.Blocks(title="Audio Summarizer") as demo:
130
  submit_btn = gr.Button("Summarize")
131
  output = gr.Textbox(label="Summary", lines=12)
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  submit_btn.click(
134
  fn=process_audio,
135
  inputs=[upload_audio, record_audio, url_input, sysprompt_input, userprompt_input],
 
55
  return response.choices[0].message.content
56
 
57
  except Exception as ex:
58
+ return print(f"Error from Azure OpenAI: {ex}")
59
 
60
 
61
  # --- I/O helpers ------------------------------------------------------------
 
93
  audio_b64 = encode_audio_from_path(audio_path)
94
  return summarize_audio_b64(audio_b64, sys_prompt, user_prompt)
95
 
96
+ except Exception as e:
97
+ return print(f"Error processing audio at {datetime.now()}: prompt_length={len(user_prompt)}, audio_path={audio_path}: {str(e)}")
98
+
99
+
100
  finally:
101
  for p in tmp_to_cleanup:
102
  try:
 
134
  submit_btn = gr.Button("Summarize")
135
  output = gr.Textbox(label="Summary", lines=12)
136
 
137
+ # Capture inputs for logging
138
+ if upload_audio:
139
+ upload_audio.change(
140
+ fn=lambda x: print(f"Upload audio selected: {x}"),
141
+ inputs=[upload_audio],
142
+ outputs=[],
143
+ # Reset other inputs to avoid confusion
144
+ )
145
+ if record_audio:
146
+ record_audio.change(
147
+ fn=lambda x: print(f"Record audio selected: {x}"),
148
+ inputs=[record_audio],
149
+ outputs=[],
150
+ )
151
+ if url_input:
152
+ url_input.change(
153
+ fn=lambda x: print(f"URL input changed: {x}"),
154
+ inputs=[url_input],
155
+ outputs=[],
156
+ )
157
  submit_btn.click(
158
  fn=process_audio,
159
  inputs=[upload_audio, record_audio, url_input, sysprompt_input, userprompt_input],