Skip to main content
you can synthesize in three ways, depending on how soon you need the audio and whether it is a one-shot clip or an ongoing conversation: batch (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.
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.
streaming needs the ws extra: pip install "rumik-ai[ws]".
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. you send 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.
sessions need the ws extra: pip install "rumik-ai[ws]".
session(model="muga", description=None, speaker=None, timeout=None, idle_timeout=30) returns a SpeechSession, a context manager. events yielded while iterating:
a session does not auto-reconnect if the socket drops. detect the error, open a new session, and resend. input is always whole utterances; there is no partial or streaming text input.

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.