Update app.py
Browse files285 unmodified lines28628728828928929029029129229329412 unmodified lines30730830930931031131231377 unmodified lines391392393393394395394395396397214 unmodified lines612613614616617618615616617618285 unmodified lines body = e.response.text[:800] except Exception: pass # CORRECTED LINE: Use triple quotes for multi-line f-string return pd.DataFrame(), gr.update(choices=[], value=None), f"HTTP error: {e}{body}" return pd.DataFrame(), gr.update(choices=[], value=None), f"""HTTP error: {e}{body}""" except Exception as e: return pd.DataFrame(), gr.update(choices=[], value=None), f"Load error: {e}"
12 unmodified lines # Download only if not exists (avoid re-fetch) if not os.path.exists(fpath) or os.path.getsize(fpath) == 0: fpath, url_used = fetch_mp3_by_unique_id(unique_id) html = f'URL: <a href="{url_used}" target="_blank">{url_used}</a>' html = f'<a href="{url_used}" target="_blank">Recording URL</a>' return html, fpath, fpath, "Ready ✅" except requests.HTTPError as e: body = ""77 unmodified lines msg = str(e) try: if hasattr(e, "args") and e.args: msg = msg + "
" + str(e.args[0]) msg = msg + "\n\n" + str(e.args[0]) except Exception: pass return f"Error during model call: {msg}"214 unmodified lines return (info, None, info, gr.update())
# Save to .txt and return results_text = "
".join(results_blocks) results_text = "\n\n".join(results_blocks) fname = f"/tmp/batch_analysis_{(date_str or _today_str()).strip()}_{t_from.replace(':','')}-{t_to.replace(':','')}_{int(time.time())}.txt" with open(fname, "w", encoding="utf-8") as f: f.write(results_text)app.py+6-9