Skip to content

Commit 504a2ee

Browse files
committed
Add alternative language codes to RTSP input
Introduce support for alternative language codes in AudioRTSPInputStream. Adds an optional alternative_language_codes parameter (Optional[List[str]]) to the constructor and docstring, stores it as self._alternative_language_codes (defaulting to an empty list), and includes it in the audio JSON payload sent to registered audio callbacks. No other behavior changes.
1 parent ae0bdd1 commit 504a2ee

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/om1_speech/audio/audio_rtsp_input_stream.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class AudioRTSPInputStream:
136136
A callback function that receives audio data chunks (default: None)
137137
language_code: str, optional
138138
The language for the ASR to listen. (default: en-US)
139+
alternative_language_codes: List[str], optional
140+
A list of alternative language codes for the ASR to consider (default: None)
139141
rtsp_url : str, optional
140142
The RTSP URL of the audio stream. If None, uses device or device_name to determine the URL.
141143
(default: "rtsp://localhost:8554/audio")
@@ -149,6 +151,7 @@ def __init__(
149151
audio_data_callback: Optional[Callable] = None,
150152
audio_data_callbacks: Optional[List[Callable]] = None,
151153
language_code: Optional[str] = None,
154+
alternative_language_codes: Optional[List[str]] = None,
152155
enable_tts_interrupt: bool = False,
153156
):
154157
self._rate = rate
@@ -164,6 +167,9 @@ def __init__(
164167
self._language_code = language_code
165168
logger.info(f"Using specified language code: {self._language_code}")
166169

170+
# Alternative language codes
171+
self._alternative_language_codes = alternative_language_codes or []
172+
167173
# Callback for audio data
168174
self._audio_data_callbacks = audio_data_callbacks or []
169175
self.register_audio_data_callback(audio_data_callback)
@@ -447,6 +453,7 @@ def generator(self) -> Generator[Dict[str, Union[bytes, int]], None, None]:
447453
"audio": base64.b64encode(b"".join(data)).decode("utf-8"),
448454
"rate": self._rate,
449455
"language_code": self._language_code,
456+
"alternative_language_codes": self._alternative_language_codes,
450457
}
451458
for audio_callback in self._audio_data_callbacks:
452459
audio_callback(json.dumps(response))

0 commit comments

Comments
 (0)