Use this file to discover all available pages before exploring further.
KugelAudio exposes an ElevenLabs-compatible HTTP API, so any existing integration built for ElevenLabs works by changing one line: the base_url. No other code changes required.
from elevenlabs import ElevenLabsclient = ElevenLabs( api_key="your-kugelaudio-api-key", base_url="https://api.kugelaudio.com/11labs",)audio = client.text_to_speech.convert( voice_id="480", # use client.voices.get_all() to list available voices text="Hello from KugelAudio!", model_id="kugel-1-turbo", output_format="pcm_24000",)with open("output.pcm", "wb") as f: for chunk in audio: f.write(chunk)
If your downstream system requires MP3 or µ-law (e.g. telephony platforms like Twilio), convert after receiving the PCM stream:
# MP3 — using pydub + ffmpegfrom pydub import AudioSegmentimport iopcm_bytes = b"".join(chunk for chunk in audio_stream)segment = AudioSegment( data=pcm_bytes, sample_width=2, # 16-bit frame_rate=24000, channels=1,)segment.export("output.mp3", format="mp3", bitrate="128k")
# µ-law (G.711) — using audioop (stdlib)import audiooppcm_bytes = b"".join(chunk for chunk in audio_stream)# Downsample to 8kHz first if neededpcm_8k = audioop.ratecv(pcm_bytes, 2, 1, 24000, 8000, None)[0]ulaw_bytes = audioop.lin2ulaw(pcm_8k, 2)
About stream-input: Feed text tokens as they arrive from an LLM — synthesis starts as soon as a sentence boundary is detected, minimizing time-to-first-audio. The server sends ElevenLabs-format audio frames ({"audio": "<base64>", "isFinal": false}) and closes with {"audio": "", "isFinal": true}.
import asyncio, base64, jsonimport websocketsasync def stream_tts(): url = "wss://api.kugelaudio.com/11labs/v1/text-to-speech/480/stream-input?model_id=eleven_turbo_v2&output_format=pcm_24000" async with websockets.connect(url, extra_headers={"xi-api-key": "your-api-key"}) as ws: # Send text tokens one by one (e.g. from an LLM stream) for token in ["Hello, ", "this is ", "streamed ", "speech."]: await ws.send(json.dumps({"text": token})) # Signal end of stream await ws.send(json.dumps({"text": ""})) # Receive audio frames with open("output.pcm", "wb") as f: async for msg in ws: frame = json.loads(msg) if frame.get("isFinal"): break if audio := frame.get("audio"): f.write(base64.b64decode(audio))asyncio.run(stream_tts())