fish.audio platform api sdk
Project description
Fish Audio Python SDK
To provide convenient Python program integration for https://docs.fish.audio.
Install
pip install fish-audio-sdk
Usage
Initialize a Session
to use APIs. All APIs have synchronous and asynchronous versions. If you want to use the asynchronous version of the API, you only need to rewrite the original session.api_call(...)
to session.api_call.awaitable(...)
.
from fish_audio_sdk import Session
session = Session("your_api_key")
Text to speech
from fish_audio_sdk import Session, TTSRequest
session = Session("your_api_key")
with open("r.mp3", "wb") as f:
for chunk in session.tts(TTSRequest(text="Hello, world!")):
f.write(chunk)
Or use async version:
import asyncio
import aiofiles
from fish_audio_sdk import Session, TTSRequest
session = Session("your_api_key")
async def main():
async with aiofiles.open("r.mp3", "wb") as f:
async for chunk in session.tts.awaitable(
TTSRequest(text="Hello, world!"),
):
await f.write(chunk)
asyncio.run(main())
Reference Audio
from fish_audio_sdk import TTSRequest
TTSRequest(
text="Hello, world!",
reference_id="your_model_id",
)
Or just use ReferenceAudio
in TTSRequest
:
from fish_audio_sdk import TTSRequest, ReferenceAudio
TTSRequest(
text="Hello, world!",
references=[
ReferenceAudio(
audio=audio_file.read(),
text="reference audio text",
)
],
)
List models
models = session.list_models()
print(models)
Or use async version:
import asyncio
async def main():
models = await session.list_models.awaitable()
print(models)
asyncio.run(main())
Get a model info by id
model = session.get_model("your_model_id")
print(model)
Or use async version:
import asyncio
async def main():
model = await session.get_model.awaitable("your_model_id")
print(model)
asyncio.run(main())
Create a model
model = session.create_model(
title="test",
description="test",
voices=[voice_file.read(), other_voice_file.read()],
cover_image=image_file.read(),
)
print(model)
Or use async version:
import asyncio
async def main():
model = await session.create_model.awaitable(
title="test",
description="test",
voices=[voice_file.read(), other_voice_file.read()],
cover_image=image_file.read(),
)
print(model)
asyncio.run(main())
Delete a model
session.delete_model("your_model_id")
Or use async version:
import asyncio
async def main():
await session.delete_model.awaitable("your_model_id")
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fish_audio_sdk-2024.10.22.tar.gz
(27.1 kB
view details)
Built Distribution
File details
Details for the file fish_audio_sdk-2024.10.22.tar.gz
.
File metadata
- Download URL: fish_audio_sdk-2024.10.22.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8330ee0f4b442ba4d7b6103a6a0009f19427d646b7de3574e9e0f54af4e18bba |
|
MD5 | 678b202af2986b9f78191e16cd1f3b03 |
|
BLAKE2b-256 | 0f7e66c752e254582ef239ddec0b1032f589e6c62171d3918a9e15a7baf034cb |
File details
Details for the file fish_audio_sdk-2024.10.22-py3-none-any.whl
.
File metadata
- Download URL: fish_audio_sdk-2024.10.22-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88ec58e74a605fb98871bc2b440ed5f1d2cd0320725ccc5dd52aa4e34c54738e |
|
MD5 | 30d0a71cc95c0dcbbd644d47bdfa9a1c |
|
BLAKE2b-256 | c4a6c64529f003ad04abbc7d6b7f5efb5bbbd0f4b0e502cbf8858c687d599c24 |