Add alternative_language_codes to AudioInputStream#110
Open
openminddev wants to merge 3 commits intomainfrom
Open
Add alternative_language_codes to AudioInputStream#110openminddev wants to merge 3 commits intomainfrom
openminddev wants to merge 3 commits intomainfrom
Conversation
Introduce an optional alternative_language_codes parameter to AudioInputStream to support passing multiple language hints for ASR. The constructor accepts alternative_language_codes (List[str]) and stores it as _alternative_language_codes (defaulting to an empty list). The value is included in emitted payloads (generator and audio callbacks) and respected when filling the buffer from remote input. Tests updated and new tests added to cover initialization, generator output, remote buffer parsing, and audio callbacks with alternative language codes.
There was a problem hiding this comment.
Pull request overview
This PR adds support for providing multiple ASR language hints by introducing an optional alternative_language_codes parameter on AudioInputStream, storing it internally, and including it in generator/callback payloads.
Changes:
- Add
alternative_language_codestoAudioInputStreamconstructor and include it in emitted generator/callback payloads. - Update existing tests to expect the new payload field and add new tests around initialization/generator/remote input/callbacks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
src/om1_speech/audio/audio_input_stream.py |
Accepts/stores alternative_language_codes and includes it in emitted payloads. |
tests/om1_speech/audio/test_audio_input_stream.py |
Updates expectations and adds coverage for initialization, generator output, remote buffer fill, and callbacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+308
to
+324
| stream = AudioInputStream(remote_input=True) | ||
| stream.start() | ||
|
|
||
| test_audio = b"remote_audio_data" | ||
| remote_data = json.dumps( | ||
| { | ||
| "audio": base64.b64encode(test_audio).decode("utf-8"), | ||
| "rate": 48000, | ||
| "language_code": "ja-JP", | ||
| "alternative_language_codes": ["zh-CN", "ko-KR"], | ||
| } | ||
| ) | ||
|
|
||
| stream.fill_buffer_remote(remote_data) | ||
|
|
||
| buffered_data = stream._buff.get() | ||
| assert buffered_data == test_audio |
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.
Include a timestamp in audio generator responses by importing time and adding a "timestamp": int(time.time()) field to the payload in AudioInputStream and AudioRTSPInputStream. Clarified generator docstrings to reflect that single chunks are yielded and removed the logic that merged multiple immediate chunks. Updated tests to patch time, assert the timestamp value, and remove the now-invalid multi-chunk aggregation test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce an optional alternative_language_codes parameter to AudioInputStream to support passing multiple language hints for ASR. The constructor accepts alternative_language_codes (List[str]) and stores it as _alternative_language_codes (defaulting to an empty list). The value is included in emitted payloads (generator and audio callbacks) and respected when filling the buffer from remote input. Tests updated and new tests added to cover initialization, generator output, remote buffer parsing, and audio callbacks with alternative language codes.