On this page

Rime

Stream text-to-speech with Rime voices using rime(): conversational voices built for phone calls. No Rime package needed.

rime() is a text-to-speech provider. It streams speech over Rime's WebSocket API and can return telephony audio directly.

Install

npm install voiceai-sdk

Set RIME_API_KEY on your server, and keep it out of browser bundles.

Quickstart

TypeScript
import { createSession } from "voiceai-sdk";
import { rime } from "voiceai-sdk/rime";

await using session = await createSession(rime({ voice: process.env.VOICE_ID }));
const speech = await session.speak("Your order has shipped.", { format: "wav" });
await Bun.write("shipped.wav", speech.audio);

This writes the spoken sentence to shipped.wav. await using closes the session when the block ends.

What it supports

FeatureSupportNotes
Speech-to-text (transcribe)NoUse a pipeline with a speech-to-text provider
Streaming transcripts (listen)No
Text-to-speech (speak)Yes
Streaming speechYes
Speech-to-speechNo
Word timingsNoNot returned
Speaker labelsNo
InterruptionsYes
Voice list (listVoices)Yes
pause() and resume()No

The capability matrix compares these with every other provider.

Speak

Iterate session.speak to send audio as it is produced. Pass an async iterable of text, such as a model's output, and speech starts before the text is finished.

TypeScript
import { createSession } from "voiceai-sdk";
import { rime } from "voiceai-sdk/rime";

await using session = await createSession(rime({ voice: process.env.VOICE_ID }));

for await (const chunk of session.speak("Let me check that for you.")) {
  player.write(chunk.data);
}

Voices

listVoices returns the voices you can pass as voice.

TypeScript
import { listVoices } from "voiceai-sdk";
import { rime } from "voiceai-sdk/rime";

const voices = await listVoices(rime());
console.log(voices.filter((v) => v.language.startsWith("en")).map((v) => v.id));

Use it in a pipeline

Rime only speaks. For a conversation, combine it with a provider that streams transcripts.

TypeScript
import { createSession } from "voiceai-sdk";
import { rime } from "voiceai-sdk/rime";
import { deepgram } from "voiceai-sdk/deepgram";

await using session = await createSession({ stt: deepgram(), tts: rime({ voice: process.env.VOICE_ID }) });
await session.converse(async (text) => answer(text));

Configuration

Pass options to rime(). Options that have an environment variable fall back to it.

OptionTypeDefaultEnv var
apiKeystringRIME_API_KEY
voicestringRequired
modelstringProvider default

Call the API directly

session.native is the Rime WebSocket while speech is streaming.

TypeScript
import { createSession } from "voiceai-sdk";
import { rime } from "voiceai-sdk/rime";

await using session = await createSession(rime({ voice: process.env.VOICE_ID }));
console.log(session.native.url);

Limitations

  • transcribe and listen fail with unsupported. Pair Rime with a speech-to-text provider.
  • wordTimings is false, so transcripts of what was spoken come from the text you sent, not from the audio.

How it works

  • When the session encoding is mulaw, Rime returns 8 kHz mu-law directly and the SDK doesn't resample.
  • interrupt() sends a clear message and drops queued audio.

Next steps

Was this page helpful?

Esc

Loading…

↑↓ navigate openCtrl J preview