Skip to content

Commit 453254a

Browse files
committed
docs: update README to reflect new API features and improve installation instructions
1 parent 6f3103e commit 453254a

1 file changed

Lines changed: 79 additions & 92 deletions

File tree

README.md

Lines changed: 79 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,88 @@
11
# Fish Audio Python SDK
22

3-
[![PyPI version](https://badge.fury.io/py/fish-audio-sdk.svg)](https://badge.fury.io/py/fish-audio-sdk)
3+
[![PyPI version](https://img.shields.io/pypi/v/fish-audio-sdk.svg)](https://badge.fury.io/py/fish-audio-sdk)
44
[![Python Version](https://img.shields.io/badge/python-3.9+-blue)](https://pypi.org/project/fish-audio-sdk/)
55
[![PyPI - Downloads](https://img.shields.io/pypi/dm/fish-audio-sdk)](https://pypi.org/project/fish-audio-sdk/)
66
[![codecov](https://img.shields.io/codecov/c/github/fishaudio/fish-audio-python)](https://codecov.io/gh/fishaudio/fish-audio-python)
77
[![License](https://img.shields.io/github/license/fishaudio/fish-audio-python)](https://github.com/fishaudio/fish-audio-python/blob/main/LICENSE)
88

99
The official Python library for the Fish Audio API.
1010

11-
[Documentation](https://docs.fish.audio) | [API Reference](https://docs.fish.audio) | [Examples](./examples/) | [Discord](https://fish.audio)
11+
## Notice: New API Available
1212

13-
---
13+
The SDK now includes a modern `fishaudio` API with improved ergonomics, better type safety, and enhanced features.
1414

15-
## Important: New API Available
15+
For new projects, use the `fishaudio` module. For existing projects using the legacy API, see the [Legacy SDK section](#legacy-sdk) below
1616

17-
> **We've released a major update to the Fish Audio Python SDK!**
18-
>
19-
> The new API (`fishaudio` module) offers improved ergonomics, better type safety, and enhanced features. The legacy SDK (`fish_audio_sdk` module) continues to be supported for existing projects, but we recommend using the new API for all new development.
20-
>
21-
> **Migration:** Both APIs are available in the same package. You can migrate at your own pace. See our [Migration Guide](https://docs.fish.audio) for details.
17+
## API Documentation
2218

23-
---
19+
See the Python API Documentation and Reference
2420

25-
## Quick Start
21+
## Installation
2622

27-
### Installation
23+
This package is available on PyPI:
2824

2925
```bash
3026
pip install fish-audio-sdk
3127
```
3228

33-
### Basic Usage
29+
You may install from source by running the following command in the repository root:
3430

35-
```python
36-
from fishaudio import FishAudio
37-
from fishaudio.utils import save
38-
39-
# Set your API key via environment variable: export FISH_AUDIO_API_KEY="your-api-key"
40-
# Or pass it directly: FishAudio(api_key="your-api-key")
41-
client = FishAudio()
42-
43-
# Convert text to speech
44-
audio = client.tts.convert(text="Hello from Fish Audio!")
45-
save(audio, "output.mp3")
31+
```bash
32+
python -m pip install .
4633
```
4734

48-
[Get your API key](https://fish.audio) | [Full Getting Started Guide](https://docs.fish.audio)
35+
## Usage
4936

50-
---
37+
The client will need to be configured with an API key, which you can obtain from [Fish Audio](https://fish.audio/app/api-keys).
5138

52-
## Key Features
39+
```python
40+
from fishaudio import FishAudio
5341

54-
- **Text-to-Speech** - Natural-sounding voice synthesis with multiple voice options
55-
- **Voice Cloning** - Create custom voices using reference audio samples
56-
- **Real-time Streaming** - Low-latency audio generation via WebSocket connections
57-
- **Speech-to-Text (ASR)** - Accurate automatic speech recognition with language detection
58-
- **Voice Management** - Create, update, and organize custom voice models
59-
- **Sync and Async APIs** - Full support for both synchronous and asynchronous operations
60-
- **Type Safety** - Complete type hints with Pydantic models throughout
42+
client = FishAudio() # Automatically reads from the FISH_AUDIO_API_KEY environment variable
6143

62-
---
44+
client = FishAudio(api_key="your-api-key") # Or provide the API key directly
45+
```
6346

64-
## Examples
47+
The SDK provides [text-to-speech](#text-to-speech), [voice cloning](#instant-voice-cloning), [speech recognition](#speech-recognition-asr), and [voice management](#voice-management) capabilities.
6548

6649
### Text-to-Speech
6750

51+
Convert text to natural-sounding speech with support for multiple voices, formats, and real-time streaming.
52+
53+
#### Basic
54+
6855
```python
6956
from fishaudio import FishAudio
70-
from fishaudio.utils import save
57+
from fishaudio.utils import save, play
7158

7259
client = FishAudio()
73-
audio = client.tts.convert(text="Hello, world!")
74-
save(audio, "output.mp3")
60+
61+
audio = client.tts.convert(text="Hello, world!") # Default voice and settings
62+
play(audio) # Play audio directly
63+
64+
audio = client.tts.convert(text="Welcome to Fish Audio SDK!")
65+
save(audio, "output.mp3") # You can also save to a file
7566
```
7667

77-
### Voice Cloning with Reference Audio
68+
#### With Reference Voice
69+
70+
Use a reference voice ID to ensure consistent voice characteristics across generations:
7871

7972
```python
80-
from fishaudio import FishAudio
73+
# Use an existing voice by ID
74+
audio = client.tts.convert(
75+
text="This will sound like the reference voice!",
76+
reference_id="802e3bc2b27e49c2995d23ef70e6ac89" # Energetic Male
77+
)
78+
```
8179

82-
client = FishAudio()
80+
#### Instant Voice Cloning
81+
82+
Immediately clone a voice from a short audio sample:
8383

84-
# Use a reference voice for cloning
84+
```python
85+
# Clone a voice from audio sample
8586
with open("reference.wav", "rb") as f:
8687
audio = client.tts.convert(
8788
text="This will sound like the reference voice!",
@@ -90,25 +91,30 @@ with open("reference.wav", "rb") as f:
9091
)
9192
```
9293

93-
### Real-time Streaming
94+
#### Real-time Streaming
95+
96+
For low-latency and real-time applications, stream audio as text is processed:
9497

9598
```python
9699
from fishaudio import FishAudio
97100
from fishaudio.utils import play
98101

99102
client = FishAudio()
100103

101-
# Stream audio in real-time
102-
audio_stream = client.tts.stream(
103-
text="This audio streams as it's generated",
104-
latency="balanced"
105-
)
104+
# Stream text chunks and receive audio in real-time
105+
def text_chunks():
106+
yield "Hello, "
107+
yield "this is "
108+
yield "streaming audio!"
106109

110+
audio_stream = client.tts.stream_websocket(text_chunks(), latency="balanced")
107111
play(audio_stream)
108112
```
109113

110114
### Speech Recognition (ASR)
111115

116+
To transcribe audio to text:
117+
112118
```python
113119
from fishaudio import FishAudio
114120

@@ -120,22 +126,34 @@ with open("audio.wav", "rb") as f:
120126
print(result.text)
121127
```
122128

123-
### List and Filter Voices
129+
### Voice Management
130+
131+
Manage voice references and list available voices.
124132

125133
```python
126134
from fishaudio import FishAudio
127135

128136
client = FishAudio()
129137

130138
# List available voices
131-
voices = client.voices.list(language="en")
139+
voices = client.voices.list(language="en", tags="male")
140+
141+
# Get a specific voice by ID
142+
voice = client.voices.get(voice_id="802e3bc2b27e49c2995d23ef70e6ac89")
132143

133-
for voice in voices:
134-
print(f"{voice.title} - {voice.id}")
144+
# Create a custom voice
145+
with open("voice_sample.wav", "rb") as f:
146+
new_voice = client.voices.create(
147+
title="My Custom Voice",
148+
voices=[f.read()],
149+
description="My cloned voice"
150+
)
135151
```
136152

137153
### Async Usage
138154

155+
You can also use the SDK in asynchronous applications:
156+
139157
```python
140158
import asyncio
141159
from fishaudio import AsyncFishAudio
@@ -149,7 +167,9 @@ async def main():
149167
asyncio.run(main())
150168
```
151169

152-
### Check Account Credits
170+
### Account
171+
172+
Check your remaining API credits, usage, and account details:
153173

154174
```python
155175
from fishaudio import FishAudio
@@ -159,58 +179,25 @@ credits = client.account.get_credits()
159179
print(f"Remaining credits: {credits.credit}")
160180
```
161181

162-
[More examples in /examples directory](./examples/)
163-
164-
---
165-
166-
## Documentation
167-
168-
- [API Reference](https://docs.fish.audio) - Complete API documentation with all parameters and options
169-
- [Tutorials & Guides](https://docs.fish.audio) - Step-by-step tutorials for common use cases
170-
- [Examples](./examples/) - Sample code demonstrating various features
171-
- [Migration Guide](https://docs.fish.audio) - Guide for upgrading from the legacy SDK
172-
173-
---
174-
175-
## Requirements
176-
177-
- Python 3.9 or higher
178-
- Fish Audio API key - [Get one here](https://fish.audio)
179182

180183
### Optional Dependencies
181184

182-
For audio playback utilities:
185+
For audio playback utilities to help with playing and saving audio files, install the `utils` extra:
183186

184187
```bash
185188
pip install fish-audio-sdk[utils]
186189
```
187190

188-
This installs `sounddevice` and `soundfile` for the `play()` utility function.
189-
190-
---
191-
192-
## Community & Support
193-
194-
- [Discord Community](https://fish.audio) - Join our community for discussions and support
195-
- [GitHub Issues](https://github.com/fishaudio/fish-audio-python/issues) - Report bugs or request features
196-
- [Documentation](https://docs.fish.audio) - Comprehensive guides and API reference
197-
198-
---
199-
200-
## License
201-
202-
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
203-
204-
---
205-
206191
## Legacy SDK
207192

208-
The legacy `fish_audio_sdk` module is still available for existing projects:
193+
The legacy `fish_audio_sdk` module continues to be supported for existing projects:
209194

210195
```python
211196
from fish_audio_sdk import Session
212197

213198
session = Session("your_api_key")
214199
```
215200

216-
We recommend migrating to the new `fishaudio` module for new projects. See our [Migration Guide](https://docs.fish.audio) for assistance.
201+
For complete legacy SDK documentation, see the [Legacy API Documentation](https://docs.fish.audio/legacy).
202+
203+
We recommend migrating to the new `fishaudio` module - see our [Migration Guide](https://docs.fish.audio) for assistance.

0 commit comments

Comments
 (0)