Skip to content

Commit 67a7c71

Browse files
author
James Walker
committed
Fix non-multichannel sessions
1 parent 61ccbb8 commit 67a7c71

4 files changed

Lines changed: 23 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ 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+
## [4.0.4] - 2025-06-09
9+
10+
- Fixed non-multichannel sessions bugging out after adding multichannel support
11+
12+
813
## [4.0.3] - 2025-06-06
914

1015
- Fixed microphone transcription tests not working after adding multichan dz support

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.3
1+
4.0.4

speechmatics/cli.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -810,21 +810,19 @@ def rt_main(args):
810810

811811
def run(stream=None, channel_stream_pairs=None):
812812
try:
813-
# Pass in either stream or channel_stream_pairs depending on what != None
814-
# Dynamically construct the args based on the input
815-
args_list = [transcription_config]
813+
stream_or_channel_stream_pairs = None
816814
if stream is not None:
817-
args_list.append(stream)
815+
stream_or_channel_stream_pairs = stream
818816
elif channel_stream_pairs is not None:
819-
args_list.append(None) # This skips the stream argument
820-
args_list.append(channel_stream_pairs)
817+
stream_or_channel_stream_pairs = channel_stream_pairs
821818
else:
822819
raise SystemExit(
823820
"Neither stream nor channel_stream_pairs were provided."
824821
)
825822
api.run_synchronously(
826-
*args_list,
827-
audio_settings=get_audio_settings(args),
823+
stream_or_channel_stream_pairs,
824+
transcription_config,
825+
get_audio_settings(args),
828826
from_cli=True,
829827
extra_headers=extra_headers,
830828
)

speechmatics/client.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from collections import defaultdict
1010
from contextlib import AsyncExitStack
1111
import copy
12+
from io import IOBase
1213
import json
1314
import logging
1415
import os
@@ -521,9 +522,8 @@ async def _communicate(self, stream, audio_settings):
521522

522523
async def run(
523524
self,
525+
stream: Union[IOBase, dict],
524526
transcription_config: TranscriptionConfig,
525-
stream: Optional[Any] = None,
526-
channel_stream_pairs=None,
527527
audio_settings: AudioSettings = None,
528528
from_cli: bool = False,
529529
extra_headers: Dict = None,
@@ -552,7 +552,14 @@ async def run(
552552
:raises Exception: Can raise any exception returned by the
553553
consumer/producer tasks.
554554
"""
555-
if channel_stream_pairs:
555+
# Check we get either a dict or a file-like object
556+
channel_stream_pairs = None
557+
if isinstance(stream, dict):
558+
# Case where stream is channel stream pairs
559+
channel_stream_pairs = stream
560+
561+
# Set channel_stream pairs if provided
562+
if channel_stream_pairs is not None:
556563
opened_streams = {}
557564
self._stream_exits = AsyncExitStack()
558565
for channel_name, path in channel_stream_pairs.items():
@@ -564,6 +571,7 @@ async def run(
564571
self.channel_stream_pairs = opened_streams
565572
else:
566573
self.channel_stream_pairs = None
574+
567575
self.transcription_config = transcription_config
568576
self._language_pack_info = None
569577
await self._init_synchronization_primitives()

0 commit comments

Comments
 (0)