Skip to content
Merged
Show file tree
Hide file tree
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
37 changes: 36 additions & 1 deletion deepgram/clients/live/v1/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,44 @@ async def _start(self) -> None:
)
await self._emit(LiveTranscriptionEvents.Error, error=error)
except json.JSONDecodeError as e:
await self._emit(LiveTranscriptionEvents.Error, e.code)
error: ErrorResponse = {
"type": "Exception",
"description": "Unknown error _listening",
"message": f"{e}",
"variant": "",
}
self.logger.error("exception: json.JSONDecodeError: %s", str(e))
await self._emit(LiveTranscriptionEvents.Error, error=error)
self.logger.debug("AsyncLiveClient._start LEAVE")
except websockets.exceptions.ConnectionClosedOK as e:
if e.code == 1000:
self.logger.notice("_start(1000) exiting gracefully")
self.logger.debug("AsyncLiveClient._start LEAVE")
return
else:
error: ErrorResponse = {
"type": "Exception",
"description": "Unknown error _start",
"message": f"{e}",
"variant": "",
}
self.logger.error(
f"WebSocket connection closed with code {e.code}: {e.reason}"
)
self._emit(LiveTranscriptionEvents.Error, error=error)
self.logger.debug("AsyncLiveClient._start LEAVE")
raise
except Exception as e:
error: ErrorResponse = {
"type": "Exception",
"description": "Unknown error _start",
"message": f"{e}",
"variant": "",
}
self._emit(LiveTranscriptionEvents.Error, error)
self.logger.error("Exception in _start: %s", error=error)
self.logger.debug("AsyncLiveClient._start LEAVE")
raise

async def send(self, data):
"""
Expand Down
14 changes: 8 additions & 6 deletions deepgram/clients/live/v1/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ def _listening(self) -> None:
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}")
"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
Expand Down