diff --git a/src/deepgram/listen/v1/socket_client.py b/src/deepgram/listen/v1/socket_client.py index 10ea9759..2d0e54fa 100644 --- a/src/deepgram/listen/v1/socket_client.py +++ b/src/deepgram/listen/v1/socket_client.py @@ -25,6 +25,8 @@ ListenV1UtteranceEndEvent, ) +_BINARY_TYPES = (bytes, bytearray) + # Response union type (Listen only receives JSON events) V1SocketClientResponse = typing.Union[ ListenV1ResultsEvent, @@ -131,7 +133,7 @@ def __init__(self, *, websocket: websockets_sync_connection.Connection): def _is_binary_message(self, message: typing.Any) -> bool: """Determine if a message is binary data.""" - return isinstance(message, (bytes, bytearray)) + return isinstance(message, _BINARY_TYPES) def _handle_binary_message(self, message: bytes) -> typing.Any: """Handle a binary message (returns as-is)."""