Skip to content
Closed
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
1 change: 0 additions & 1 deletion .github/workflows/check-actionlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
checkactionlint:
name: Check actionlint
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'deepgram/deepgram-python-sdk'
runs-on: ubuntu-latest
steps:

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
build:
name: Change to Main/Release Branch
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'deepgram/deepgram-python-sdk'
runs-on: ubuntu-latest
steps:

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
checklint:
name: Check shell
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'deepgram/deepgram-python-sdk'
runs-on: ubuntu-latest
steps:

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-mdlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
checkmdlint:
name: Check mdlint
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'deepgram/deepgram-python-sdk'
runs-on: ubuntu-latest
steps:

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-shell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
checkshell:
name: Check shell
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'deepgram/deepgram-python-sdk'
runs-on: ubuntu-latest
steps:

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
checkstatic:
name: Check static
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'deepgram/deepgram-python-sdk'
runs-on: ubuntu-latest
steps:

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-yaml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
checkmdlint:
name: Check mdlint
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'deepgram/deepgram-python-sdk'
runs-on: ubuntu-latest
steps:

Expand Down
19 changes: 15 additions & 4 deletions deepgram/clients/common/v1/abstract_async_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from abc import ABC, abstractmethod

import websockets
from websockets.client import WebSocketClientProtocol

from ....audio import Speaker
from ....utils import verboselogs
Expand All @@ -25,6 +24,8 @@
)
from .websocket_events import WebSocketEvents

WEBSOCKETS_CURRENT_MAJOR_VERSION = int(websockets.version.version.split(".", 1)[0])

ONE_SECOND = 1
HALF_SECOND = 0.5
DEEPGRAM_INTERVAL = 5
Expand All @@ -44,7 +45,7 @@ class AbstractAsyncWebSocketClient(ABC): # pylint: disable=too-many-instance-at
_endpoint: str
_websocket_url: str

_socket: Optional[WebSocketClientProtocol] = None
_socket: Optional[websockets.connect] = None

_listen_thread: Union[asyncio.Task, None]
_delegate: Optional[Speaker] = None
Expand Down Expand Up @@ -134,10 +135,20 @@ async def start(
url_with_params = append_query_params(self._websocket_url, combined_options)

try:
ws_connect_kwargs: Dict = {
"ping_interval": PING_INTERVAL,
}

# Backward compatibility support with older versions of websockets.
# "extra_headers" was renamed to "additional_headers" in Python Websockets version 14
if WEBSOCKETS_CURRENT_MAJOR_VERSION < 14:
ws_connect_kwargs["extra_headers"] = combined_headers
else:
ws_connect_kwargs["additional_headers"] = combined_headers

self._socket = await websockets.connect(
url_with_params,
extra_headers=combined_headers,
ping_interval=PING_INTERVAL,
**ws_connect_kwargs,
)
self._exit_event.clear()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
httpx = "^0.25.2"
websockets = "^12.0"
websockets = ">=12.0"
typing-extensions = "^4.9.0"
dataclasses-json = "^0.6.3"
aiohttp = "^3.9.1"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pip install -r requirements.txt

# standard libs
websockets==12.*
websockets>=12.0
httpx==0.*
dataclasses-json==0.*
dataclasses==0.*
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
packages=find_packages(exclude=["tests"]),
install_requires=[
"httpx>=0.25.2",
"websockets>=12.0,<14.0",
"websockets>=12.0",
"dataclasses-json>=0.6.3",
"typing_extensions>=4.9.0",
"aiohttp>=3.9.1",
Expand Down