Official Python SDK for the OuteAI text-to-speech API.
Project description
OuteAI Python SDK
Official Python SDK for the OuteAI text-to-speech API at https://outeai.com.
Installation
From PyPI:
pip install outeai
From this repository:
cd outeai
pip install .
Build distributable artifacts:
cd outeai
python -m pip install build
python -m build
Install async support:
pip install "outeai[async]"
Authentication
Create an API key in your OuteAI account, then pass it to the client with Authorization: Bearer <key>.
The SDK uses https://outeai.com by default, so you do not need to set a base URL unless you want to override it.
Quick Start
from outeai import OuteAI
client = OuteAI(api_key="YOUR_OUTEAI_API_KEY")
voices = client.list_voices()
voice_id = voices[0]["voice_id"]
audio = client.generate_speech(
text="Hello from OuteAI.",
voice_id=voice_id,
)
audio.save("hello.wav")
client.close()
Streaming Audio
from outeai import OuteAI
client = OuteAI(api_key="YOUR_OUTEAI_API_KEY")
with client.stream_speech(
text="This is a streaming response from OuteAI.",
voice_id="vc_your_voice_id",
) as stream:
stream.save("streamed.wav")
You can also iterate the WAV bytes yourself:
with client.stream_speech(
text="Chunked audio output.",
voice_id="vc_your_voice_id",
) as stream:
for chunk in stream:
print(f"received {len(chunk)} bytes")
Voice IDs
Voice clone management is intentionally not part of this SDK surface. Pass an existing voice_id into the TTS methods.
Async Usage
import asyncio
from outeai import AsyncOuteAI
async def main() -> None:
client = AsyncOuteAI(api_key="YOUR_OUTEAI_API_KEY")
voices = await client.list_voices()
voice_id = voices[0]["voice_id"]
audio = await client.generate_speech(
text="Hello from the async OuteAI client.",
voice_id=voice_id,
)
audio.save("hello-async.wav")
await client.stream_speech_to_file(
"stream-async.wav",
text="This file was written from the async streaming client.",
voice_id=voice_id,
)
await client.close()
asyncio.run(main())
Available Methods
client.health()client.list_voices()client.generate_speech(...)client.generate_speech_to_file(...)client.stream_speech(...)client.stream_speech_to_file(...)AsyncOuteAI.health()AsyncOuteAI.list_voices()AsyncOuteAI.generate_speech(...)AsyncOuteAI.generate_speech_to_file(...)AsyncOuteAI.stream_speech(...)AsyncOuteAI.stream_speech_to_file(...)
Error Handling
API errors raise OuteAIAPIError.
from outeai import OuteAI, OuteAIAPIError
client = OuteAI(api_key="YOUR_OUTEAI_API_KEY")
try:
client.list_voices()
except OuteAIAPIError as exc:
print(exc.status_code)
print(exc.code)
print(exc.message)
Notes
- TTS responses are returned as WAV audio.
- The default TTS model is
outetts_1_pro. voice_idis required for generation and must belong to the authenticated user.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file outeai-2.0.0.tar.gz.
File metadata
- Download URL: outeai-2.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d64d736e997f6c437ada963064e40b3ca78d1aae058284522b4ac8dad1349278
|
|
| MD5 |
6129882a6b30a8bc0bf1c31cc2d7d536
|
|
| BLAKE2b-256 |
58446c6388f9c9f514bd95ecfb0cda51024d95b215f778ea503fd59dd42b27c9
|
File details
Details for the file outeai-2.0.0-py3-none-any.whl.
File metadata
- Download URL: outeai-2.0.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
991f2644c721ec785476ea8261cb3b853a17850efbb440fff15801d50188595f
|
|
| MD5 |
824f1fd42222f2c70049524d42e5b9c6
|
|
| BLAKE2b-256 |
67be47045a9a29cc3b218bb70d15978c26a029d1a11ec3b4bc7399c88cb5827d
|