Repository navigation
fix(streaming): accept bytearray and memoryview audio in stream() - #266
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
RaphaelFakhri
force-pushed
the
fix/stream-bytes-like-chunks
branch
from
September 30, 2026 09:21
4226746 to
f2da806
Compare
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.
Summary
RealTimeTranscriber.stream()andAsyncRealTimeTranscriber.stream()only recognizebytesas a single buffer. Abytearrayormemoryviewfalls through to the iterable branch and is enqueued oneintat a time. The write thread then raisesValueError: Attempted to send invalid message: <class 'int'>. In the sync client the thread dies silently and no audio is sent. In the async client the write task fails with an unretrieved exception.Changes
stream()acceptsbytes,bytearrayandmemoryview, and copies the latter two tobytesbefore enqueuing.bytearrayormemoryviewchunks get the same conversion._as_bytes_chunkhelper instreaming/v3/_base.py.This matches how
transcribe_live()and the dual-channel streamer already treatbytearrayandmemoryview.Testing
test_streaming.py) and async tests (test_streaming_async.py) for a single buffer and an iterable of chunks, parametrized overbytearrayandmemoryview.pytest tests/unit/test_streaming.py tests/unit/test_streaming_async.py -k bytes_likereports 6 failed.pytest tests/unitreports 739 passed.ruff format --check assemblyai/streamingis clean.