Skip to main content

Prerequisites

Before you begin, make sure you have:

Installation

Install the Python SDK using pip or uv:
pip install kugelaudio
Or with uv (recommended):
uv add kugelaudio

Basic Usage

Initialize the Client

from kugelaudio import KugelAudio

# Initialize with your API key
client = KugelAudio(api_key="your_api_key")

Generate Speech

# Generate speech
audio = client.tts.generate(
    text="Welcome to KugelAudio! This is high-quality text-to-speech.",
    model_id="kugel-1-turbo",
)

# Save to file
audio.save("output.wav")

# Or get the raw bytes
wav_bytes = audio.to_wav_bytes()

Stream Audio

For lower latency, stream audio chunks as they’re generated:
# Synchronous streaming
for chunk in client.tts.stream(
    text="Hello, this is streaming audio.",
    model_id="kugel-1-turbo",
):
    if hasattr(chunk, 'audio'):
        # Process audio chunk immediately
        print(f"Chunk {chunk.index}: {len(chunk.audio)} bytes")
        # play_audio(chunk.audio)
For async applications:
import asyncio

async def stream_audio():
    async for chunk in client.tts.stream_async(
        text="Async streaming example.",
        model_id="kugel-1-turbo",
    ):
        if hasattr(chunk, 'audio'):
            # Process chunk
            pass

asyncio.run(stream_audio())

Working with Voices

List Available Voices

# List all voices
voices = client.voices.list()

for voice in voices:
    print(f"{voice.id}: {voice.name}")
    print(f"  Languages: {', '.join(voice.supported_languages)}")

# Filter by language
german_voices = client.voices.list(language="de")

Use a Specific Voice

audio = client.tts.generate(
    text="Hello with a specific voice!",
    model_id="kugel-1-turbo",
    voice_id=123,  # Use a specific voice ID
)

Next Steps