Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down