You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SDK now includes a modern `fishaudio` API with improved ergonomics, better type safety, and enhanced features.
14
14
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
16
16
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
22
18
23
-
---
19
+
See the Python API Documentation and Reference
24
20
25
-
## Quick Start
21
+
## Installation
26
22
27
-
### Installation
23
+
This package is available on PyPI:
28
24
29
25
```bash
30
26
pip install fish-audio-sdk
31
27
```
32
28
33
-
### Basic Usage
29
+
You may install from source by running the following command in the repository root:
34
30
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 .
46
33
```
47
34
48
-
[Get your API key](https://fish.audio) | [Full Getting Started Guide](https://docs.fish.audio)
35
+
## Usage
49
36
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).
51
38
52
-
## Key Features
39
+
```python
40
+
from fishaudio import FishAudio
53
41
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
61
43
62
-
---
44
+
client = FishAudio(api_key="your-api-key") # Or provide the API key directly
45
+
```
63
46
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.
65
48
66
49
### Text-to-Speech
67
50
51
+
Convert text to natural-sounding speech with support for multiple voices, formats, and real-time streaming.
52
+
53
+
#### Basic
54
+
68
55
```python
69
56
from fishaudio import FishAudio
70
-
from fishaudio.utils import save
57
+
from fishaudio.utils import save, play
71
58
72
59
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
75
66
```
76
67
77
-
### Voice Cloning with Reference Audio
68
+
#### With Reference Voice
69
+
70
+
Use a reference voice ID to ensure consistent voice characteristics across generations:
78
71
79
72
```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
+
```
81
79
82
-
client = FishAudio()
80
+
#### Instant Voice Cloning
81
+
82
+
Immediately clone a voice from a short audio sample:
83
83
84
-
# Use a reference voice for cloning
84
+
```python
85
+
# Clone a voice from audio sample
85
86
withopen("reference.wav", "rb") as f:
86
87
audio = client.tts.convert(
87
88
text="This will sound like the reference voice!",
@@ -90,25 +91,30 @@ with open("reference.wav", "rb") as f:
90
91
)
91
92
```
92
93
93
-
### Real-time Streaming
94
+
#### Real-time Streaming
95
+
96
+
For low-latency and real-time applications, stream audio as text is processed:
94
97
95
98
```python
96
99
from fishaudio import FishAudio
97
100
from fishaudio.utils import play
98
101
99
102
client = FishAudio()
100
103
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
0 commit comments