`serve` keeps generating after a client disconnects mid-stream
When a client of the /tts endpoint disconnects mid-stream, the response generator is closed but the worker thread in generate_data_with_state keeps generating and decoding the remaining text.
This wastes compute, and can lead to concurrent use of the tts_model instance if another request starts before the abandoned generation finishes. The docs state, "Server mode does not support concurrent requests."
Repro: start pocket-tts serve, request a long text, kill the client after the first bytes, watch the process keep a core busy until the generation is done.
Proposed fix in #228: pass a threading.Event into generate_audio_stream() that the server sets when the client disconnects; generation ends early through the normal termination path. Numbers from that PR: on a single core, cancellation cuts interrupt-to-next-reply latency from ~7.9 s to ~0.27 s for Python API users.
Source: kyutai-labs/pocket-tts