Stream
Send the call's audio to your WebSocket server in real time, and play audio back.
Send the call's audio to your WebSocket server in real time, and play audio back.
stream sends the call's audio to your WebSocket server in real time, and can play audio from your server back to the caller. Use it to connect your own speech or AI model to a call.
connect: true. Without it the call hangs up about a second after the stream starts.audio.drachtio.org subprotocol, or the connection fails.| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Your WebSocket endpoint, wss:// or ws://. |
connect | boolean | No | true answers the call and holds it for as long as the stream runs. Set it to true. |
track | string | No | Which side of the call to send: inbound_track, outbound_track or both_tracks. |
outputSamplingRate | integer | No | Sample rate of the audio sent to your socket: 8000 or 16000. Audio is 16-bit little-endian signed PCM. |
bidirectionalSamplingRate | integer | No | Sample rate of the audio your socket sends back: 8000 or 16000. Set it whenever your socket plays audio to the caller. |
inputSamplingRate | integer | No | Optional hint about the sample rate of the source audio. |
name | string | No | A label echoed back in status events. |
record | boolean | No | Record the streamed audio. |
headerMetadata | string | No | A flat JSON object, as a string. It arrives in the first WebSocket text frame as its headers field, not as HTTP headers. |
openMetadata | string | No | Any string. It arrives in the first WebSocket text frame. |
statusCallback | string | No | URL that receives stream-started, stream-stopped and stream-error. |
statusEvents | string | No | The status events you want, separated by spaces: stream-started stream-stopped stream-error. |
import { sauti } from "@sautikit/node";
res.json(sauti.stream({
url: "wss://your-app.example.com/audio",
connect: true,
track: "both_tracks",
bidirectionalSamplingRate: 16000,
}));{
"actions": [
{
"stream": {
"url": "wss://your-app.example.com/audio",
"connect": true,
"track": "both_tracks",
"bidirectionalSamplingRate": 16000
}
}
]
}<Stream url="wss://your-app.example.com/audio" connect="true" track="both_tracks" bidirectionalSamplingRate="16000" />