This release is a pre-release and may not be stable for production use.
Rime SDK for Python
Generate speech with TTS, or send speech to Prism and receive a spoken reply.
Both APIs use the Rime client. Your application handles audio capture and playback.
Install
Requires Python 3.11 or later and uv. This package is in alpha.
Start in a new directory, or skip uv init if you already have a Python project:
uv init rime-quickstart
cd rime-quickstart
uv add --prerelease=allow rimelabs-sdk
export RIME_API_KEY="your-api-key"
Get a TTS API key from the Rime dashboard.
An explicit Rime(api_key="...") overrides RIME_API_KEY. The SDK does not load .env files.
The commands below use a macOS or Linux shell.
TTS: save speech
Save this as tts.py. It writes a playable speech.wav file with no audio-device dependencies.
import asyncio
import wave
from rimelabs_sdk import Rime
async def main():
async with (
Rime(timeout=60) as client,
client.tts.stream("Your appointment is confirmed for tomorrow.") as audio,
):
with wave.open("speech.wav", "wb") as wav:
wav.setnchannels(1)
wav.setsampwidth(2)
wav.setframerate(24000)
async for chunk in audio:
wav.writeframesraw(chunk)
print("Saved speech.wav")
asyncio.run(main())
Run uv run tts.py, then open speech.wav in your audio player.
A failed run can leave a partial file. Only a successful exit confirms completion.
Coda is the default model. Use Rime(model="mistv3") for Mist v3, or pass
voice="your-voice" to client.tts.stream(...) to select a voice for that model.
The default output is mono 24 kHz PCM16. The example adds its WAV header.
To supply text from an LLM, pass an async iterable of strings instead of a string.
The SDK handles sentence boundaries.
Prism: send recorded speech
Prism needs a deployment that serves its realtime API. Obtain the endpoint,
credentials, and voice from your deployment operator. The TTS endpoint does not serve Prism.
Set RIME_API_KEY to the credential for that deployment if it differs from your TTS key.
export PRISM_URL="wss://your-prism-host/v1/realtime"
export PRISM_VOICE="your-deployment-voice"
You can omit PRISM_VOICE if the deployment has a default voice.
Record a short question and export it as question.wav, using 16 kHz, mono, signed 16-bit PCM WAV.
Save the following as prism.py beside that file. It sends the recording at capture speed,
then sends silence so Prism can detect the end of speech. The spoken reply goes to reply.wav.
import asyncio
import os
import wave
from rimelabs_sdk import Rime
from rimelabs_sdk import realtime as r
async def main():
with wave.open("question.wav", "rb") as wav:
if (wav.getnchannels(), wav.getsampwidth(), wav.getframerate()) != (1, 2, 16000):
raise ValueError("question.wav must be 16 kHz mono PCM16")
data = wav.readframes(wav.getnframes())
if not data or len(data) % 2:
raise ValueError("question.wav must contain complete PCM16 samples")
async with (
asyncio.timeout(60),
Rime() as client,
client.realtime.connect(
endpoint=os.environ["PRISM_URL"],
voice=os.getenv("PRISM_VOICE"),
instructions="Give short, clear answers.",
) as session,
):
async def send():
offset = 0
while True:
frame = data[offset : offset + 1280].ljust(1280, b"\0")
await session.send_audio(r.AudioChunk(data=frame))
offset += 1280
await asyncio.sleep(0.04)
async with asyncio.TaskGroup() as tasks:
sending = tasks.create_task(send())
with wave.open("reply.wav", "wb") as wav:
wav.setnchannels(1)
wav.setsampwidth(2)
wav.setframerate(24000)
async for event in session.events:
payload = event.payload
if isinstance(payload, r.AudioDelta):
wav.writeframesraw(payload.audio.data)
elif isinstance(payload, r.FaultEvent):
raise r.RimeRealtimeError(payload.error)
elif isinstance(payload, r.ResponseEnded):
if payload.status != "completed":
raise RuntimeError(f"Response {payload.status}: {payload.reason}")
sending.cancel()
break
else:
raise RuntimeError("Session closed before the reply ended")
print("Saved reply.wav")
asyncio.run(main())
Run uv run prism.py, then open reply.wav. This example has a 60-second deadline.
It saves audio without playing it, so it sends no playback receipt.
For live conversations, your application must capture microphone audio, play replies,
stop playback on interruption, and report the actual played position to Prism.
TTS settings do not configure Prism sessions.
Help and licenses
See Rime documentation for API keys, TTS models, and deployment information. The examples above run with the installed package. No source checkout is required.
SDK code uses the MIT license. The Prism protocol module uses Apache 2.0. License texts and notices are included in the distribution.
Metadata
Release files for rimelabs-sdk 0.1.0a9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rimelabs_sdk-0.1.0a9.tar.gz | 135.9 kB | Without provenance | Details for rimelabs_sdk-0.1.0a9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rimelabs_sdk-0.1.0a9-py3-none-any.whl | Python 3 | none | any | Details for rimelabs_sdk-0.1.0a9-py3-none-any.whl |
Total release size: 177.7 kB
Release files / rimelabs_sdk-0.1.0a9.tar.gz
| Download URL | rimelabs_sdk-0.1.0a9.tar.gz |
|---|---|
| Size | 135.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c1249c153a566f7b8c5d60aaf205fe2a9aaea1c4c259a9be8be3b19ba0b4baa
|
|
BLAKE2b-256 checksum How to use checksums |
bd48c9d986177c1e64bcbc445fef366daee141df03070b12d8ed6db2d80f3c80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / rimelabs_sdk-0.1.0a9-py3-none-any.whl
| Download URL | rimelabs_sdk-0.1.0a9-py3-none-any.whl |
|---|---|
| Size | 41.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5116764099c56c9b2e77573450c200af3cf101309291a78b3d1a04f3decc904f
|
|
BLAKE2b-256 checksum How to use checksums |
1f2db9863fd9e515eb17ec64dd932c974daae74f2616aa6f1d24cc0b30b451e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for rimelabs-sdk 0.1.0a9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.