From 4488b267334b266edbd23aa6a003847c8c799ce3 Mon Sep 17 00:00:00 2001 From: Felix Lu <58391009+lumpinif@users.noreply.github.com> Date: Thu, 26 Nov 2026 23:50:44 -0800 Subject: [PATCH] docs: fix the async realtime example in the README The example awaited client.tts.stream_websocket(), which is an async generator, so it raised TypeError, and passed the result to play(), which takes a synchronous iterable. Show a complete example that iterates the stream. Quote the extras install so it works in zsh. --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f1ca832..f446770 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ The official Python library for the Fish Audio API pip install fish-audio-sdk # With audio playback utilities -pip install fish-audio-sdk[utils] +pip install "fish-audio-sdk[utils]" ``` ## Authentication @@ -245,13 +245,23 @@ play(audio_stream) **Asynchronous:** ```python +import asyncio +from fishaudio import AsyncFishAudio + async def text_chunks(): yield "Hello, " yield "this is " yield "streaming!" -audio_stream = await client.tts.stream_websocket(text_chunks(), latency="balanced") -play(audio_stream) +async def main(): + client = AsyncFishAudio() + # stream_websocket is an async generator: iterate it, don't await the call + audio_stream = client.tts.stream_websocket(text_chunks(), latency="balanced") + with open("output.mp3", "wb") as f: + async for chunk in audio_stream: + f.write(chunk) + +asyncio.run(main()) ``` [Learn more](https://docs.fish.audio/developer-guide/sdk-guide/python/websocket)