diff --git a/CHANGELOG.md b/CHANGELOG.md index 2292a0f..7c7baaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ 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-06 + +- Changing async run wrapper to use explicit arguments to fix multichannel tests in aladdin + ## [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/examples/transcribe_from_youtube/youtube_transcribe.py b/examples/transcribe_from_youtube/youtube_transcribe.py index 4024e81..9af57c3 100644 --- a/examples/transcribe_from_youtube/youtube_transcribe.py +++ b/examples/transcribe_from_youtube/youtube_transcribe.py @@ -52,7 +52,11 @@ def main(args): def run(stream): try: - api.run_synchronously(stream, transcription_config, AudioSettings()) + api.run_synchronously( + stream=stream, + transcription_config=transcription_config, + audio_settings=AudioSettings(), + ) except KeyboardInterrupt: # Gracefully handle Ctrl-C, else we get a huge stack-trace. LOGGER.warning("Keyboard interrupt received.") diff --git a/speechmatics/cli.py b/speechmatics/cli.py index e34d4a1..51b77d5 100755 --- a/speechmatics/cli.py +++ b/speechmatics/cli.py @@ -810,20 +810,14 @@ def rt_main(args): def run(stream=None, channel_stream_pairs=None): 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: + if stream is None and channel_stream_pairs is None: raise SystemExit( "Neither stream nor channel_stream_pairs were provided." ) api.run_synchronously( - *args_list, + transcription_config=transcription_config, + stream=stream, + channel_stream_pairs=channel_stream_pairs, audio_settings=get_audio_settings(args), from_cli=True, extra_headers=extra_headers, diff --git a/speechmatics/client.py b/speechmatics/client.py index 93e3eaa..915a5f3 100644 --- a/speechmatics/client.py +++ b/speechmatics/client.py @@ -553,6 +553,10 @@ async def run( consumer/producer tasks. """ if channel_stream_pairs: + if not isinstance(channel_stream_pairs, dict): + raise TypeError( + "channel_stream_pairs must be a dict of {str: file-like or path}" + ) opened_streams = {} self._stream_exits = AsyncExitStack() for channel_name, path in channel_stream_pairs.items(): @@ -569,6 +573,9 @@ async def run( await self._init_synchronization_primitives() if extra_headers is None: extra_headers = {} + else: + if not isinstance(extra_headers, dict): + raise TypeError("extra_headers must be a dict") if audio_settings is None: audio_settings = AudioSettings() if ( @@ -632,13 +639,35 @@ def stop(self): """ self._session_needs_closing = True - def run_synchronously(self, *args, timeout=None, **kwargs): + def run_synchronously( + self, + transcription_config: TranscriptionConfig, + *, + stream: Optional[Any] = None, + channel_stream_pairs: Optional[Dict[str, Any]] = None, + audio_settings: Optional[AudioSettings] = None, + from_cli: bool = False, + extra_headers: Optional[Dict] = None, + timeout=None, + ): """ Run the transcription synchronously. :raises asyncio.TimeoutError: If the given timeout is exceeded. """ # pylint: disable=no-value-for-parameter - asyncio.run(asyncio.wait_for(self.run(*args, **kwargs), timeout=timeout)) + asyncio.run( + asyncio.wait_for( + self.run( + transcription_config=transcription_config, + stream=stream, + channel_stream_pairs=channel_stream_pairs, + audio_settings=audio_settings, + from_cli=from_cli, + extra_headers=extra_headers, + ), + timeout=timeout, + ) + ) async def send_message(self, message_type: str, data: Optional[Any] = None): """