Skip to content

Commit 90534ee

Browse files
committed
Fixed language code getting added to URL query parameter
1 parent 9c7becb commit 90534ee

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.0.1] - 2024-12-09
9+
10+
### Fixed
11+
12+
- Language code getting added to URL query parameter
13+
814
## [3.0.0] - 2024-11-12
915

1016
### Changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0
1+
3.0.1

speechmatics/client.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,20 +472,26 @@ async def run(
472472
extra_headers["Authorization"] = token
473473

474474
url = self.connection_settings.url
475-
if not url.endswith(self.transcription_config.language.strip()):
476-
if url.endswith("/"):
477-
url += self.transcription_config.language.strip()
478-
else:
479-
url += f"/{self.transcription_config.language.strip()}"
480475

481476
# Extend connection url with sdk version information
482477
cli = "-cli" if from_cli is True else ""
483478
version = get_version()
484479
parsed_url = urlparse(url)
480+
485481
query_params = dict(parse_qsl(parsed_url.query))
486482
query_params["sm-sdk"] = f"python{cli}-{version}"
487483
updated_query = urlencode(query_params)
488-
updated_url = urlunparse(parsed_url._replace(query=updated_query))
484+
485+
url_path = parsed_url.path
486+
if not url_path.endswith(self.transcription_config.language.strip()):
487+
if url_path.endswith("/"):
488+
url_path += self.transcription_config.language.strip()
489+
else:
490+
url_path += f"/{self.transcription_config.language.strip()}"
491+
492+
updated_url = urlunparse(
493+
parsed_url._replace(path=url_path, query=updated_query)
494+
)
489495

490496
try:
491497
async with websockets.connect( # pylint: disable=no-member

0 commit comments

Comments
 (0)