aiOla Text-to-Speech SDK
The aiOla Text-to-Speech SDK provides Python bindings for aiOla's text-to-speech services, enabling high-quality voice synthesis with multiple voice options.
Features
- Text-to-speech synthesis
- Multiple voice options
- Streaming support
- Customizable audio formats
- Error handling and logging
Installation
pip install aiola-tts
Usage
Basic Usage
from aiola_tts import AiolaTtsClient, AudioFormat
client = AiolaTtsClient(
base_url="your-base-url",
bearer_token="your-bearer-token",
audio_format=AudioFormat.LINEAR16
)
audio_data = client.synthesize(
text="Hello, world!",
voice="af_bella"
)
with open("output.wav", "wb") as f:
f.write(audio_data)
Streaming Support
streamed_audio = client.synthesize_stream(
text="Hello, world!",
voice="af_bella"
)
with open("streamed_output.wav", "wb") as f:
f.write(streamed_audio)
Available Voices
The SDK supports multiple voice options:
"af_bella"
"af_nicole"
"af_sarah"
"af_sky"
"am_adam"
"am_michael"
"bf_emma"
"bf_isabella"
"bm_george"
"bm_lewis"
Audio Format Configuration
The SDK supports two audio formats:
from aiola_tts import AudioFormat
client = AiolaTtsClient(
base_url="your-base-url",
bearer_token="your-bearer-token",
audio_format=AudioFormat.LINEAR16
)
client = AiolaTtsClient(
base_url="your-base-url",
bearer_token="your-bearer-token",
audio_format=AudioFormat.PCM
)
Development
To install development dependencies:
pip install -e ".[dev]"
Error Handling
The SDK provides comprehensive error handling:
try:
audio_data = client.synthesize("Hello, world!")
except requests.exceptions.RequestException as e:
print(f"Error: {str(e)}")
License
MIT License