Skip to content

HTTP TTS read fails after partial audio iteration #312

Open

Description

@codebanditssss

Bug

HTTP TTS streams cannot continue after partial iteration. read() and aread()
promise to read the rest of the audio, but they raise httpx.StreamConsumed.
Replacement iteration fails for the same reason.

async with tts.stream("Hello.") as speech:
    chunks = speech.aiter_bytes()
    first = await chunks.__anext__()
    await chunks.aclose()  # closes the wrapper, not the speech stream
    remaining = await speech.aread()  # raises StreamConsumed

The synchronous iter_bytes() followed by read() has the same failure.
Each SDK wrapper starts a new httpx response iterator; streamed response bodies
are single-use. The expected result is the remaining bytes, without replaying
the first chunk or making another request.

Reproduction and validation

Reproduced at upstream 0ba094c through the public sync/async SDK APIs and a
loopback chunked HTTP server. The server sends head, waits for the caller, then
sends tail. Five regression cases fail with StreamConsumed; two controls pass.
Retaining one body cursor per speech stream makes all seven pass.

Verified on Python 3.12/httpx 0.28.1/pydantic 2.14.4 and Python
3.11/httpx 0.22.0/pydantic 1.10.17/websockets 11.0.3.

This concerns successful HTTP responses, not the refused-response cleanup in
#281. It does not
promise resumption after transport cancellation/failure or concurrent reads
of the same stream.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions