Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions deepgram/clients/live/v1/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: MIT
import json
from websockets.sync.client import connect
import websockets
import threading
import time
import logging, verboselogs
Expand Down Expand Up @@ -191,22 +192,34 @@ def _listening(self) -> None:
data,
)

except Exception as e:
except websockets.exceptions.ConnectionClosedOK as e:
if e.code == 1000:
self.logger.notice("_listening(1000) exiting gracefully")
self.logger.debug("LiveClient._listening LEAVE")
return
else:
error: ErrorResponse = {
"type": "Exception",
"description": "Unknown error _listening",
"message": f"{e}",
"variant": "",
}
self.logger.error(f"WebSocket connection closed with code {e.code}: {e.reason}")
self._emit(LiveTranscriptionEvents.Error, error)
self.logger.debug("LiveClient._listening LEAVE")
raise

except Exception as e:
error: ErrorResponse = {
"type": "Exception",
"description": "Unknown error _listening",
"message": f"{e}",
"variant": "",
}
self._emit(LiveTranscriptionEvents.Error, error)

self.logger.error("Exception in _listening: %s", str(e))
self.logger.debug("LiveClient._listening LEAVE")
raise

def _processing(self) -> None:
self.logger.debug("LiveClient._processing ENTER")
Expand Down