emit capture_saved SSE event when async transcription completes
This commit is contained in:
@@ -716,6 +716,16 @@ def transcribe_and_save(tmp_path, timestamp, nextcloud_url, nextcloud_user, next
|
|||||||
url = f"{captures_dir}/{filename}"
|
url = f"{captures_dir}/{filename}"
|
||||||
req_lib.put(url, data=content_md.encode("utf-8"), auth=nc_auth, timeout=30)
|
req_lib.put(url, data=content_md.encode("utf-8"), auth=nc_auth, timeout=30)
|
||||||
print(f"Async transcription saved: {filename}")
|
print(f"Async transcription saved: {filename}")
|
||||||
|
# Notify SSE clients that transcription is complete
|
||||||
|
try:
|
||||||
|
import requests as _req
|
||||||
|
_req.post("http://localhost:8000/api/events/notify", json={
|
||||||
|
"type": "capture_saved",
|
||||||
|
"filename": filename,
|
||||||
|
"timestamp": timestamp,
|
||||||
|
}, timeout=3)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if os.path.exists(tmp_path):
|
if os.path.exists(tmp_path):
|
||||||
os.unlink(tmp_path)
|
os.unlink(tmp_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user