Skip to content

Commit 54bc101

Browse files
authored
feat: implement v1 sdk (#29)
* refactor: format and bring python 3.9 support Signed-off-by: James Ding <[email protected]> * feat: implement Fish Audio SDK v1.0.0 with dual module support Major changes: - Introduce new 'fishaudio' module with modern Python SDK architecture - Restore legacy 'fish_audio_sdk' module for backwards compatibility - Rename package to 'fish-audio-sdk' (from 'fish-audio') - Add comprehensive test suite (unit and integration tests) - Implement real-time WebSocket streaming for TTS - Add utility functions for audio playback and file operations - Support Python 3.9-3.14 - Include examples and documentation New Features: - Sync/async client support (FishAudio/AsyncFishAudio) - TTS with streaming and real-time WebSocket support - Voice management (list, get, create, delete) - ASR (automatic speech recognition) support - Account/credits management - Event-based streaming (TextEvent, FlushEvent) - Audio utilities (play, save, stream) Breaking Changes: - New SDK uses 'fishaudio' module instead of 'fish_audio_sdk' - Legacy 'fish_audio_sdk' module maintained for compatibility Signed-off-by: James Ding <[email protected]> * feat: add output directory and save audio fixture for integration tests Signed-off-by: James Ding <[email protected]> * chore: add Apache 2.0 license and update pyproject.toml to reflect new licensing * feat: refactor WebSocket client handling and improve audio event processing --------- Signed-off-by: James Ding <[email protected]>
1 parent 864863c commit 54bc101

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+6957
-653
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FISH_AUDIO_API_KEY=

.github/workflows/ci.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/python.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Python
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
lint:
10+
name: Lint & Format
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v4
17+
18+
- name: Check formatting
19+
run: uv run ruff format --check .
20+
21+
- name: Lint code
22+
run: uv run ruff check .
23+
24+
type-check:
25+
name: Type Check
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Set up Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: "3.x"
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v4
35+
- name: Install dependencies
36+
run: uv sync
37+
- name: Run mypy
38+
run: uv run mypy src/fishaudio --ignore-missing-imports
39+
40+
test:
41+
name: Test Python ${{ matrix.python-version }}
42+
runs-on: ubuntu-latest
43+
strategy:
44+
matrix:
45+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.x"]
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Set up Python
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: ${{ matrix.python-version }}
52+
- name: Install uv
53+
uses: astral-sh/setup-uv@v4
54+
- name: Install dependencies
55+
run: uv sync
56+
- name: Run tests with coverage
57+
run: uv run pytest tests/unit/ -v --cov=src/fishaudio --cov-report=xml --cov-report=term
58+
- name: Upload coverage to Codecov
59+
uses: codecov/codecov-action@v4
60+
if: matrix.python-version == '3.x'
61+
with:
62+
files: ./coverage.xml
63+
fail_ci_if_error: false
64+
65+
integration:
66+
name: Integration Tests
67+
runs-on: ubuntu-latest
68+
needs: [test]
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Set up Python
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: "3.x"
76+
77+
- name: Install uv
78+
uses: astral-sh/setup-uv@v4
79+
80+
- name: Install dependencies
81+
run: uv sync
82+
83+
- name: Run integration tests
84+
run: uv run pytest tests/integration/ -v
85+
env:
86+
FISH_AUDIO_API_KEY: ${{ secrets.FISH_AUDIO_API_KEY }}
87+
88+
- name: Upload Test Artifacts
89+
uses: actions/upload-artifact@v4
90+
if: always()
91+
with:
92+
name: test-audio-output
93+
path: output/
94+
95+
build:
96+
name: Build Package
97+
runs-on: ubuntu-latest
98+
needs: [lint, type-check, test, integration]
99+
steps:
100+
- uses: actions/checkout@v4
101+
- name: Install uv
102+
uses: astral-sh/setup-uv@v4
103+
- name: Build package
104+
run: uv build
105+
- name: Check package
106+
run: uv run python -c "import fishaudio; print(f'fishaudio v{fishaudio.__version__}')"
107+
- name: Upload build artifacts
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: dist
111+
path: dist/
112+
113+
publish:
114+
name: Publish to PyPI
115+
runs-on: ubuntu-latest
116+
needs: [lint, type-check, test, integration, build]
117+
if: startsWith(github.ref, 'refs/tags/')
118+
environment: pypi
119+
permissions:
120+
id-token: write
121+
steps:
122+
- uses: actions/checkout@v4
123+
- name: Install uv
124+
uses: astral-sh/setup-uv@v4
125+
- name: Build package
126+
run: uv build
127+
- name: Publish to PyPI
128+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,7 @@ cython_debug/
159159
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162-
#.idea/
162+
.idea/
163+
164+
# Test output
165+
output/

.mcp.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"mcpServers": {
3+
"fish-audio": {
4+
"type": "http",
5+
"url": "https://docs.fish.audio/mcp"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)