Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -363,9 +363,13 @@ async def audio_ws(websocket: WebSocket, session_id: str = ""):
|
|
| 363 |
audio_q, stop_ev = sess["audio"], sess["stop"]
|
| 364 |
loop = asyncio.get_event_loop()
|
| 365 |
try:
|
| 366 |
-
while
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
try:
|
| 368 |
-
ab, fm = await loop.run_in_executor(None, lambda: audio_q.get(timeout=
|
| 369 |
except Exception:
|
| 370 |
continue
|
| 371 |
await websocket.send_bytes(struct.pack("<f", fm) + ab)
|
|
|
|
| 363 |
audio_q, stop_ev = sess["audio"], sess["stop"]
|
| 364 |
loop = asyncio.get_event_loop()
|
| 365 |
try:
|
| 366 |
+
while True:
|
| 367 |
+
if stop_ev.is_set():
|
| 368 |
+
try: await websocket.send_json({"type": "ended"}) # worker ended (quota/grant) -> tell client
|
| 369 |
+
except Exception: pass
|
| 370 |
+
break
|
| 371 |
try:
|
| 372 |
+
ab, fm = await loop.run_in_executor(None, lambda: audio_q.get(timeout=0.5))
|
| 373 |
except Exception:
|
| 374 |
continue
|
| 375 |
await websocket.send_bytes(struct.pack("<f", fm) + ab)
|