Skip to content

Commit

Permalink
Make Speechmatics client compatible with websockets 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dumitrugutu committed Nov 12, 2024
1 parent b565984 commit 94369bb
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.0] - 2024-11-12

### Changed

- Renamed `extra_headers` to `additional_headers` in `websockets.connect()` to support WebSockets version 14.0,
as per [documentation](https://websockets.readthedocs.io/en/stable/howto/upgrade.html#arguments-of-connect)
- Updated `speechmatics-python` to require `Python >= 3.9`, aligning with WebSockets 14.0

## [2.0.3] - 2024-11-11

speechmatics-python `2.0.3` is the last version supporting `Python 3.8`
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.3
3.0.0
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
websockets>=10.0,<=13.1
websockets>=14.0
httpx[http2]~=0.23
polling2~=0.5
toml~=0.10.2
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ def get_version(fname):
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Multimedia :: Sound/Audio :: Speech",
"Topic :: Software Development :: Libraries :: Python Modules",
],
include_package_data=True,
python_requires=">=3.7",
python_requires=">=3.9",
)
2 changes: 1 addition & 1 deletion speechmatics/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ async def run(
ping_timeout=self.connection_settings.ping_timeout_seconds,
# Don't limit the max. size of incoming messages
max_size=None,
extra_headers=extra_headers,
additional_headers=extra_headers,
) as self.websocket:
await self._communicate(stream, audio_settings)
finally:
Expand Down
4 changes: 2 additions & 2 deletions tests/mock_rt_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def dummy_add_transcript():
async def mock_server_handler(websocket, logbook):
mock_server_handler.next_audio_seq_no = 1
address, _ = websocket.remote_address
logbook.connection_request = websocket.request_headers
logbook.path = websocket.path
logbook.connection_request = websocket.request.headers
logbook.path = websocket.request.path

# Begin a connection
logging.info("%s %s", address, "connected")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async def test_send_message(mock_server, message_type: str, message_data: Any):
ssl=ws_client.connection_settings.ssl_context,
ping_timeout=ws_client.connection_settings.ping_timeout_seconds,
max_size=None,
extra_headers=None,
additional_headers=None,
) as ws_client.websocket:
await ws_client.send_message(message_type, message_data)
assert message_type in [
Expand Down Expand Up @@ -377,7 +377,7 @@ def call_exit(*args, **kwargs):
except Exception:
assert len(connect_mock.mock_calls) == 1
assert (
connect_mock.mock_calls[0][2]["extra_headers"] == extra_headers
connect_mock.mock_calls[0][2]["additional_headers"] == extra_headers
), f"Extra headers don't appear in the call list = {connect_mock.mock_calls}"


Expand Down

0 comments on commit 94369bb

Please sign in to comment.