This release is a pre-release and may not be stable for production use.
Rime SDK for Python
Stream speech from a string or async text source with Rime.
Install
Requires Python 3.11 or later. This package is in alpha.
uv add --prerelease=allow rimelabs-sdk
export RIME_API_KEY="your-api-key"
Quick start
Save this as speech.py and run uv run speech.py:
import asyncio
from rimelabs_sdk import Rime
async def main():
async with Rime() as client:
async with client.tts.stream("Hello. This is Rime.") as audio:
with open("speech.pcm", "wb") as output:
async for chunk in audio:
output.write(chunk)
print(audio.request_id)
asyncio.run(main())
Output is raw mono 24 kHz signed 16-bit little-endian PCM. Configure your player for this format; there is no WAV header.
Stream incoming text
Add this async text source before main() in the quick start:
async def text():
yield "Hello. "
yield "This text arrives in separate chunks."
Use client.tts.stream(text()) in the same audio loop. The SDK handles sentence
boundaries. Do not await tts.stream(); entering its async context or reading
the first chunk starts work.
Configuration
Select Mist v3 with Rime(model="mistv3"). Mist v1 and v2 are not supported.
| Model | Standard endpoint | Default voice |
|---|---|---|
coda |
coda.api.rime.ai:443 |
clementine |
mistv3 |
mist.api.rime.ai:443 |
astra |
Client options
Rime(...) option |
Default | Meaning |
|---|---|---|
api_key |
RIME_API_KEY |
API key; an explicit value overrides the environment |
model |
"coda" |
Model for speech and discovery |
endpoint |
Model's standard endpoint | Custom hostname and optional port for speech and discovery |
timeout |
None |
Positive seconds for an overall deadline; None disables it |
Authentication uses bearer tokens over TLS. The SDK does not load .env files.
Custom deployments use Rime(model="coda", endpoint="host:8443"). Omit the scheme
and path. TLS is required; the default port is 443. Model defaults still apply.
Synthesis options
Pass these options to client.tts.stream(text, ...):
| Option | Default | Meaning |
|---|---|---|
voice |
Model's default voice | Voice name from client.voices.list() |
language |
"en" |
Language code |
audio_format |
AudioFormat.PCM_24000 |
Output profile, imported from rimelabs_sdk |
timeout |
Client setting | Seconds; pass None to disable the overall deadline |
Audio formats
Both profiles return raw audio without a file header.
AudioFormat profile |
Encoding | Sample rate | Channels |
|---|---|---|---|
PCM_24000 |
Signed 16-bit little-endian PCM | 24 kHz | Mono |
MULAW_8000 |
G.711 mu-law | 8 kHz | Mono |
Chunks contain complete sample frames, but their sizes vary. Inspect the read-only
audio.format.encoding, audio.format.sample_rate, and audio.format.channels.
Timeouts
An overall deadline includes pauses between reads. Disabling it leaves internal connection and progress limits active. Discovery allows at most 10 seconds; a shorter supplied timeout takes precedence.
Discover voices and languages
List voices and languages inside main():
async with Rime(model="mistv3") as client:
voices = await client.voices.list(language="en")
languages = await client.languages.list()
print(voices, languages)
Both return string lists and accept timeout. Omit language to disable filtering.
Errors and cancellation
Replace the quick start's final asyncio.run(main()) to report SDK errors and request IDs:
from rimelabs_sdk import RimeError
try:
asyncio.run(main())
except RimeError as error:
print(f"Speech failed: {error}; request_id={error.request_id}")
raise
Each SDK error inherits from RimeError:
| Error | Meaning |
|---|---|
RimeAuthenticationError |
Missing or rejected credentials |
RimePermissionError |
Access denied |
RimeInputError |
Invalid input or client use |
RimeResourceLimitError |
Service resource limit reached |
RimeUnavailableError |
Service unavailable |
RimeTimeoutError |
Overall or internal deadline reached |
RimeAudioFormatError |
Unsupported or unexpected audio format |
RimeCancelledError |
Operation cancelled |
RimeStreamError |
Other stream or transport failure |
Partial audio can arrive before an error. Output is complete only after successful iteration. Synthesis is not retried automatically.
Keep the stream's async with block to cancel unfinished work on exit.
await audio.cancel() stops one operation; await client.close() stops all client
work. Both are safe to repeat. A client belongs to one process and event loop.
Python task cancellation remains asyncio.CancelledError.
License
The SDK uses the MIT License.
Metadata
Release files for rimelabs-sdk 0.1.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rimelabs_sdk-0.1.0a2.tar.gz | 66.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rimelabs_sdk-0.1.0a2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 85.1 kB
Release files / rimelabs_sdk-0.1.0a2.tar.gz
| Download URL | rimelabs_sdk-0.1.0a2.tar.gz |
|---|---|
| Size | 66.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5df5001c439b7c0385f6bbfaa5a8e8c995430ea8d96c1c71fdeec6bf247ca613
|
|
BLAKE2b-256 checksum How to use checksums |
6630e8574c6eca4300d09260685dc11190ccfa24f8780255b7126ac44fb597da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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.0a2-py3-none-any.whl
| Download URL | rimelabs_sdk-0.1.0a2-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8dd7a646158d9e1234998e2dcd3794e942029dc0745660bdda298bb2eef64a26
|
|
BLAKE2b-256 checksum How to use checksums |
84ca6a22a3eb95a9f43eda2e6c0adefa06d3051ce3670cedc54281b04efa793f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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}
|