Skip to content

Add alternative_language_codes to AudioInputStream#110

Open
openminddev wants to merge 3 commits intomainfrom
add-alternative-code
Open

Add alternative_language_codes to AudioInputStream#110
openminddev wants to merge 3 commits intomainfrom
add-alternative-code

Conversation

@openminddev
Copy link
Copy Markdown
Contributor

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.

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.
@openminddev openminddev requested a review from Copilot March 18, 2026 23:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_codes to AudioInputStream constructor 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants