create), streaming
(stream), and sessions (session). all three come in a sync and an async form.
batch synthesis
create is the simplest path: send text, get an Audio object
back (a ready-to-play 24 kHz mono WAV). reach for it whenever you can wait for the whole
clip before playing it.
- sync
- async
create(text, model="muga", ...). only text is required.
steering by model:
muga uses an inline tone tag ([happy], [sad], [excited],
[angry], [whisper], or neutral); mulberry always takes a description, plus
an optional named speaker. see prompting muga and
prompting mulberry.
the audio object
create returns an Audio holding the WAV bytes and request metadata.
create audio is always a WAV. streaming and session audio is raw PCM; use
pcm_to_wav() or the built-in save() helpers to add a WAV header.streaming
stream opens a websocket and hands you raw PCM (24 kHz mono 16-bit) as it is
generated, so playback can start before the sentence finishes synthesizing. it returns
a SpeechStream you iterate over inside a with block.
- sync
- async
stream(text, model="muga", description=None, speaker=None, timeout=None, idle_timeout=30). idle_timeout closes the socket after that many seconds with no
audio.
sessions and voice agents
a session keeps a single websocket open across a whole conversation. yousend text,
read back events as they arrive, and call interrupt() the moment the user starts
talking over the agent. this is what you build a real-time voice agent on.
session(model="muga", description=None, speaker=None, timeout=None, idle_timeout=30)
returns a SpeechSession, a context manager.
events yielded while iterating:
async
AsyncRumik is the same client with awaitable calls, so it drops straight into an async
app. create, stream, and session all work with await, async with, and
async for.
asyncio.gather runs requests in parallel over one shared connection pool. reuse a
single AsyncRumik rather than one per request.