Update app.py
Browse files
app.py
CHANGED
|
@@ -140,11 +140,18 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
| 140 |
await websocket.accept()
|
| 141 |
try:
|
| 142 |
async for response in process_audio_stream(websocket):
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
except Exception as e:
|
| 145 |
print(f"WebSocket error: {e}")
|
| 146 |
finally:
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
if __name__ == "__main__":
|
| 150 |
import uvicorn
|
|
|
|
| 140 |
await websocket.accept()
|
| 141 |
try:
|
| 142 |
async for response in process_audio_stream(websocket):
|
| 143 |
+
try:
|
| 144 |
+
await websocket.send_text(response)
|
| 145 |
+
except Exception as send_error:
|
| 146 |
+
print(f"Error sending WebSocket message: {send_error}")
|
| 147 |
+
break
|
| 148 |
except Exception as e:
|
| 149 |
print(f"WebSocket error: {e}")
|
| 150 |
finally:
|
| 151 |
+
try:
|
| 152 |
+
await websocket.close(code=1000)
|
| 153 |
+
except Exception as close_error:
|
| 154 |
+
print(f"Error closing WebSocket: {close_error}")
|
| 155 |
|
| 156 |
if __name__ == "__main__":
|
| 157 |
import uvicorn
|