diff --git a/CHANGELOG.md b/CHANGELOG.md index 2292a0f..4c1be2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ 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). +## [4.0.4] - 2025-06-09 + +- Fixed non-multichannel sessions bugging out after adding multichannel support + + ## [4.0.3] - 2025-06-06 - Fixed microphone transcription tests not working after adding multichan dz support diff --git a/VERSION b/VERSION index aa31e71..7d666cb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3 \ No newline at end of file +4.0.4 \ No newline at end of file diff --git a/speechmatics/cli.py b/speechmatics/cli.py index e34d4a1..bbdaac4 100755 --- a/speechmatics/cli.py +++ b/speechmatics/cli.py @@ -808,23 +808,12 @@ def rt_main(args): translation_config=transcription_config.translation_config, ) - def run(stream=None, channel_stream_pairs=None): + def run(stream): try: - # Pass in either stream or channel_stream_pairs depending on what != None - # Dynamically construct the args based on the input - args_list = [transcription_config] - if stream is not None: - args_list.append(stream) - elif channel_stream_pairs is not None: - args_list.append(None) # This skips the stream argument - args_list.append(channel_stream_pairs) - else: - raise SystemExit( - "Neither stream nor channel_stream_pairs were provided." - ) api.run_synchronously( - *args_list, - audio_settings=get_audio_settings(args), + stream, + transcription_config, + get_audio_settings(args), from_cli=True, extra_headers=extra_headers, ) @@ -860,7 +849,7 @@ def run(stream=None, channel_stream_pairs=None): # Here the order matters, as stream positions and diarization labels correspond to one another. channel_name = transcription_config.channel_diarization_labels[i] channel_stream_pairs[channel_name] = args["files"][i] - run(channel_stream_pairs=channel_stream_pairs) + run(stream=channel_stream_pairs) else: for filename in args["files"]: diff --git a/speechmatics/client.py b/speechmatics/client.py index 93e3eaa..61a2554 100644 --- a/speechmatics/client.py +++ b/speechmatics/client.py @@ -9,6 +9,7 @@ from collections import defaultdict from contextlib import AsyncExitStack import copy +from io import IOBase import json import logging import os @@ -521,9 +522,8 @@ async def _communicate(self, stream, audio_settings): async def run( self, + stream: Union[IOBase, Dict[str, IOBase]], transcription_config: TranscriptionConfig, - stream: Optional[Any] = None, - channel_stream_pairs=None, audio_settings: AudioSettings = None, from_cli: bool = False, extra_headers: Dict = None, @@ -537,11 +537,8 @@ async def run( :param transcription_config: Configuration for the transcription. :type transcription_config: speechmatics.models.TranscriptionConfig - :param stream: Optional file-like object which an audio stream can be read from. - :type stream: io.IOBase - - :param channel_stream_pairs: Optional dict containing channel-name stream pairs. - :type channel_stream_pairs dict[str, io.IOBase] + :param stream: Optional file-like object or Dict of file-likes which an audio stream can be read from. + :type stream: Union[IOBase, Dict[str, IOBase]], :param audio_settings: Configuration for the audio stream. :type audio_settings: speechmatics.models.AudioSettings @@ -552,7 +549,14 @@ async def run( :raises Exception: Can raise any exception returned by the consumer/producer tasks. """ - if channel_stream_pairs: + # Check we get either a dict or a file-like object + channel_stream_pairs = None + if isinstance(stream, dict): + # Case where stream is channel stream pairs + channel_stream_pairs = stream + + # Set channel_stream pairs if provided + if channel_stream_pairs is not None: opened_streams = {} self._stream_exits = AsyncExitStack() for channel_name, path in channel_stream_pairs.items(): @@ -564,6 +568,7 @@ async def run( self.channel_stream_pairs = opened_streams else: self.channel_stream_pairs = None + self.transcription_config = transcription_config self._language_pack_info = None await self._init_synchronization_primitives()