openai SDK, and print each thing you say as a line of text. The program opens a transcription session, which transcribes every turn and never replies. You pay for each turn’s audio and its transcript, and there are no instructions to write. Transcription works in any language, and you name the caller’s language with an ISO 639 code.
The second part of this guide keeps the same audio path and opens a realtime session instead, so a support agent hears the caller and answers in text.
Full code on GitHub
A terminal transcriber, and a voice-in, text-out support agent, in Python and Node.
What you’ll build
- A transcriber, in Python and Node. Speak, and each finished sentence prints with a timestamp. The Python version can also append each line to a file.
- A support agent, in Python and Node. Speak, and Sam from a fictional outdoor store answers in text about three orders held in the prompt.
Prerequisites
- A Dialog-RSN-1 API key. Sign up or log in at studio.poly.ai and create one in the API Keys tab. The quickstart walks through it.
- For Python: Python 3.12 and uv.
- For Node: Node 22.
npm installcompiles thenaudiodon2audio package, so you need a C++ toolchain. - A microphone, or a 24 kHz, 16-bit mono WAV file to stream instead.
Connect
Pass the Dialog-RSN-1 base URL and key to the client, and ask for a transcription session when you connect.url is the full realtime URL, so drop /realtime and switch the scheme to get the base. The SDK sends the key as Authorization: Bearer and parses every event into its typed models.
url defaults to wss://api.studio.poly.ai/v1/realtime. Set DIALOG_REALTIME_URL in .env, or pass --url, to point somewhere else.
Configure the session
Send asession.update with type: "transcription":
transcription.languageis the caller’s language, as an ISO 639 code such asesfor Spanish oren-US. Both programs take it as--languageand default toen.rate: 24000. The program opens the microphone at 24 kHz, so nothing resamples on the client. The service resamples to the model’s own rate.turn_detection: {"type": "server_vad"}. Each turn ends at a pause, andturn_detection.silence_duration_mssets how long that pause is (400 ms by default). A caller who pauses longer than that mid-sentence gets two lines, so raise it for slow speakers. To decide where turns end yourself, setturn_detectiontonulland sendinput_audio_buffer.commit.
session.updated echoes the session back, with type: "transcription". Each turn is transcribed on its own, and transcripts arrive in the order the turns were spoken.
Stream the microphone
The program reads 100 ms of PCM16 at a time, base64-encodes each chunk, and appends it to the input buffer:Read the transcript
For each turn, the server sendsinput_audio_buffer.speech_started, then input_audio_buffer.speech_stopped and input_audio_buffer.committed at the pause. Then the transcript arrives on two events. conversation.item.input_audio_transcription.delta streams it in pieces, and conversation.item.input_audio_transcription.completed carries the whole line with its usage in tokens. A turn that can’t be transcribed ends with .failed instead.
.completed replaces it with the final text. In Python, line() stamps the text with the time, prints it and appends it to the --out file.
Stop on invalid_request_error. It usually means the session.update was refused, which leaves the session on the server’s defaults:
Run it
--language es (npm run transcribe -- --language es in Node) for a Spanish speaker, or any other ISO 639 code. In Python, add --out notes.txt to append each line to a file.
To test without a microphone, record a clip with the macOS say command and stream it at real time:
Build a voice-in, text-out agent
A transcription session never replies. For an agent that hears the caller and answers, open a normal realtime session.support_agent.py and support_agent.js keep the client and the audio path, and change the session.
A realtime session with text output. Connect with model only, without intent=transcription, and send this session:
output_modalities: ["text"] puts the reply on response.output_text.*. A new session defaults to ["audio"], where the server speaks the reply and sends its words as response.output_audio_transcript.*. With create_response: true, Dialog-RSN-1 decides when the caller has finished and starts the reply itself.
The instructions. prompt.py and prompt.js hold everything Sam knows: three orders in different states, the return and cancellation policy, and a rule to confirm the order before giving details. There are no tools, and the data sits in the prompt. Dialog-RSN-1 hears the caller with the prompt in front of it, so the order numbers and names in it help it hear them correctly. See speech understanding.
A seeded greeting. The program prints the greeting itself and adds it to the conversation as an assistant message, so the model’s history starts with it:
--file call.wav to stream a recording instead of the microphone, and --list-devices and --device to pick a microphone.
Troubleshooting
Where to go next
- The API reference covers transcription sessions and lists every client and server event.
- The streaming text-to-speech guide gives the support agent a voice.
- The OpenAI Realtime migration guide lists every field Dialog-RSN-1 accepts and rejects.

