Skip to main content

The official Python SDK for the Rumik Silk text-to-speech API.

Project description

Rumik Python SDK

The official Python SDK for the Rumik Silk text-to-speech API.

Turn text into natural, expressive speech with a few lines of code.

Installation

pip install rumik

Real-time WebSocket streaming needs an extra dependency:

pip install "rumik[ws]"

Quickstart

from rumik import Rumik

client = Rumik(api_key="rk_live_...")  # or set the RUMIK_API_KEY env var

audio = client.speech.create(
    text="[happy] Namaste! Kaise hain aap?",
    model="muga",
)
audio.save("hello.wav")

Controlling the voice (mulberry model)

audio = client.speech.create(
    text="Hi there, how can I help you today?",
    model="mulberry",
    description="a warm 30s female voice, smooth timbre, conversational pacing",
    speaker="speaker_2",
)
audio.save("greeting.wav")

Async

For servers and high-concurrency workloads, use AsyncRumik with async/await:

import asyncio
from rumik import AsyncRumik

async def main():
    async with AsyncRumik() as client:  # reads RUMIK_API_KEY
        audio = await client.speech.create(text="Hello!", model="mulberry")
        audio.save("hello.wav")

asyncio.run(main())

Fire many requests concurrently with asyncio.gather:

async with AsyncRumik() as client:
    clips = await asyncio.gather(
        client.speech.create(text="One"),
        client.speech.create(text="Two"),
        client.speech.create(text="Three"),
    )

Real-time streaming

For voice agents and low-latency playback, stream PCM audio over a WebSocket as it is generated. Requires the websockets extra (pip install "rumik[ws]").

from rumik import Rumik

client = Rumik()
with client.speech.stream(text="Streaming in real time.", model="mulberry") as stream:
    for chunk in stream:        # raw PCM (24 kHz mono 16-bit) as it arrives
        play(chunk)             # feed your audio device

# After the stream ends:
print(stream.request_id, stream.credits_used)

Save a stream straight to a playable WAV file:

with client.speech.stream(text="Hello!", model="mulberry") as stream:
    stream.save("out.wav")

Async streaming mirrors this with async with / async for:

async with AsyncRumik() as client:
    async with client.speech.stream(text="Hello!") as stream:
        async for chunk in stream:
            await play(chunk)

The SDK handles the two-step handshake (minting a session token, then opening the WebSocket) for you — you just iterate audio.

Models

Model Steering
muga Expressive. Prefix text with a tone tag, e.g. [happy].
mulberry Faster. Use a natural-language description + speaker.

Tone tags for muga: neutral, happy, sad, excited, angry, whisper.

Configuration

client = Rumik(
    api_key="rk_live_...",   # falls back to RUMIK_API_KEY
    timeout=60.0,            # per-request timeout (seconds)
    max_retries=2,           # automatic retries on 429 / 5xx / network errors
)

Error handling

from rumik import Rumik, RateLimitError, AuthenticationError, APIStatusError

client = Rumik()
try:
    audio = client.speech.create(text="Hello")
except AuthenticationError:
    print("Check your API key.")
except RateLimitError as e:
    print(f"Slow down. Retry after {e.retry_after}s.")
except APIStatusError as e:
    print(f"API error {e.status_code}: {e}")

Audio format

Rumik Silk returns 24 kHz, mono, signed 16-bit PCM. The HTTP API wraps it in a WAV container, so audio.save("out.wav") produces a ready-to-play file.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rumik-0.2.0.tar.gz (28.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rumik-0.2.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file rumik-0.2.0.tar.gz.

File metadata

  • Download URL: rumik-0.2.0.tar.gz
  • Upload date:
  • Size: 28.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for rumik-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2d9bf8f92cd815c3a363c856f29b3d339187a24cbd00817a3c30876ffffdd4fd
MD5 6a046c81cf02cbde8ee8910253c77087
BLAKE2b-256 d10b2b4745088c1c912086f9d1389ce1a7d4c4d4f178561dc1a7a76b0417b649

See more details on using hashes here.

File details

Details for the file rumik-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rumik-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for rumik-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad96190a7d3f5b3e0c07918e13d0feedbfe347fb551112025c895ecf728bc04c
MD5 49eaddddb00c1bd4ca5c8078d1d6a4dc
BLAKE2b-256 bd48897c5ab42f38f99d5a4d83603029052531bd33efc4213f856bca520615ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page