1
Install
Python 3.11 or later, then:
av codes the audio in Opus, and includes the codec. On Linux, also install PortAudio: sudo apt install libportaudio2. On macOS and Windows it comes with sounddevice.2
Save the script
Save it as
pearl_quickstart.py.pearl_quickstart.py
3
Run it and talk
Use headphones: a terminal has no echo cancellation, and Pearl would hear itself through your speakers.Your
<AccountId>:<SecretKey> is on the API Access page of your workspace settings (API Authorization). Your <pearlId> is on your Pearl’s overview page, in the Settings popover. If your Pearl’s opening sentence uses variables, put them in CALL_DATA first: the script stops with the reason when one is missing.Pearl greets you; answer it. On macOS, allow the terminal to use the microphone the first time.Output
How the script works
- The order: create the token, open
url?token=…, wait forready, then stream. - The pacing: the sound card hands over 20 ms of the microphone every 20 ms, silence included, which is exactly what Pearl expects.
- The playback: Pearl’s frames go through an 80 ms buffer, which absorbs network jitter.
- The ending: Ctrl+C sends
hangup, answered byended. If Pearl ends the call first, the script prints itsendedand stops. - The codec: the call is in
opus_24000. Each 20 ms of the microphone is coded to one Opus packet before it is sent, and each packet from Pearl is decoded before it is played, at 48 kHz, the rate the Opus decoder returns.
Next steps
Browser App
The same conversation from a web page.
Stream WebSocket
Every message, audio format, event and limit.

