Skip to main content
Stream a recorded call to Rime speech-to-text, and your terminal prints its transcript. Partial transcripts appear while the call streams, and a final transcript follows that you can compare with the recording. A one-line change then transcribes the same call word for word. Run the script on your computer or on a server, not in a browser.
1

Install the SDK

The SDK packages are in alpha, so these commands pin the exact versions that this page was tested with. The rime-sdk repository on GitHub has the guides, examples, and options for each language.
Install uv. Then create a project and add the SDK:
2

Set your API key

The SDK reads your key from RIME_API_KEY when it creates the client, and it does not read .env files. If you need a key, create one. Then set the variable in the terminal where you will run the script:
3

Download the sample recording

This command saves a 9-second recording of a caller to your project folder. Rime text-to-speech made the recording (Coda, voice hesse). The caller says “Uh, hi. I’m calling about flight two four seven to Denver. Can I, um, move it to Friday?”
The command downloads flight.wav. It removes the 44-byte WAV header and saves the audio as flight.pcm. This file has raw 16-bit samples at 16 kHz, mono, which is the default input format of the SDK.To listen to the recording, open flight.wav in your browser. To use your own WAV or MP3 file, convert it first, as Use your own recording shows.
4

Save the script

This script sends the recording to Rime in 100-millisecond chunks, as fast as it reads the file. The script prints every update that the SDK returns. A live microphone or call delivers audio in real time, so pass that audio to the SDK as it arrives.Save the script in your project folder.
transcribe.py
The SDK sends audio and reads updates at the same time. At the end of the file, the SDK tells Rime that the utterance is over. The loop ends when the final transcript arrives.
5

Run it

Run the script with the file name of the recording:
The partial lines appear first, and the final line follows. This is the output from one run:
The output has three kinds of lines:
  • partial: the whole transcript at that time. Each partial line replaces the line before it. Do not write code that depends on the number of partials or on the text of each partial.
  • final: the complete transcript. If the script raises an error and prints no final line, find the error in Errors and limits.
  • Request: the request ID, which identifies this stream. Give it to Rime support if you have a question about the stream.
Compare the final transcript with what you heard. Written mode, the default, changed the spoken “two four seven” to 247. In this run, written mode also left out the caller’s “uh” and “um”.
To compare latency, measure from the moment the script sends the last audio chunk to the final transcript. The total run time also includes starting the script, connecting to Rime, and reading and sending the file.
6

Switch to word-for-word mode

Word-for-word mode asks for the exact words of the speaker, including fillers such as “uh” and numbers as spoken words. Change the mode line in your script, and run the script on the same recording again:
These are the final lines from the two runs:Word-for-word mode kept the caller’s “Uh” and “um”, and it wrote the flight number as the caller said it: “two four seven”. Written mode removed the fillers from this recording, but it does not promise to remove fillers. Use word-for-word mode when you need the exact wording as a record, for example in a quality or compliance review. Recognition settings explains how the two modes differ.

Use your own recording

The stream call reads headerless PCM16 samples, not audio files. Convert your recording first.
  1. Install FFmpeg.
  2. Convert the recording to 16 kHz mono PCM16. This command reads recording.mp3 and writes recording.pcm. A WAV file works the same way.
    Renaming a file to .pcm does not convert it.
  3. If the recording is in Spanish, set the language to "es" in the script. Use language in Python and Node.js, Language in Go, or TranscriptionOptions::new("es") in Rust.
  4. Run the script with recording.pcm in place of flight.pcm.
Live phone audio, such as the 8 kHz mu-law of a Twilio media stream, needs one more step, because the SDK does not decode mu-law. Where audio flows shows how to decode it and declare its rate.

Transcribe a whole file in one call

For a recording that you already have, such as a voicemail, the SDK can send the whole WAV file in one call. The call returns one final transcript and no partial transcripts. It takes the file with its WAV header, so it reads flight.wav as you downloaded it. One call takes a file of up to 16 MiB, with up to about 100 to 120 seconds of speech, as Limits explains. Save this script next to the first one:
transcribe_file.py
The script prints one line with the final transcript, and then the request ID:
To transcribe your own file, convert it to a 16 kHz mono PCM16 WAV file first. This format is the only one that Rime guarantees:
For a longer recording, stream it with append fragments over the API, as Transcribe a long recording describes.

Use the API without the SDK

Choose how to connect helps you choose WebSocket or gRPC. The WebSocket reference ends with a complete Python client that streams a WAV file. For a short WAV file in one request, use gRPC Transcribe. For a longer recording, see Transcribe a long recording.

Next

Stream live audio

Replace the file with your live audio source. The stream call does not change.

Recognition settings

Choose word-for-word or written text. Add the names that your callers say.