Skip to content

Commit

Permalink
Fixed language code getting added to URL query parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
owaisaamir committed Dec 9, 2024
1 parent 9c7becb commit 90534ee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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.1] - 2024-12-09

### Fixed

- Language code getting added to URL query parameter

## [3.0.0] - 2024-11-12

### Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0
3.0.1
18 changes: 12 additions & 6 deletions speechmatics/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,20 +472,26 @@ async def run(
extra_headers["Authorization"] = token

url = self.connection_settings.url
if not url.endswith(self.transcription_config.language.strip()):
if url.endswith("/"):
url += self.transcription_config.language.strip()
else:
url += f"/{self.transcription_config.language.strip()}"

# Extend connection url with sdk version information
cli = "-cli" if from_cli is True else ""
version = get_version()
parsed_url = urlparse(url)

query_params = dict(parse_qsl(parsed_url.query))
query_params["sm-sdk"] = f"python{cli}-{version}"
updated_query = urlencode(query_params)
updated_url = urlunparse(parsed_url._replace(query=updated_query))

url_path = parsed_url.path
if not url_path.endswith(self.transcription_config.language.strip()):
if url_path.endswith("/"):
url_path += self.transcription_config.language.strip()
else:
url_path += f"/{self.transcription_config.language.strip()}"

updated_url = urlunparse(
parsed_url._replace(path=url_path, query=updated_query)
)

try:
async with websockets.connect( # pylint: disable=no-member
Expand Down

0 comments on commit 90534ee

Please sign in to comment.