AI Streaming
The Stream action will connect the call to a WebSocket server and stream real-time audio data. This can be used for scenarios like real-time AI processing or interactive voice response systems.
- Curl
- Node.js
- Python
Streaming action JSON
[
{
action: "stream",
ws_url: "ws://example.tcp.ngrok.url",
listen_mode: "both",
voice_quality: "8000",
stream_on_answer: true
}
]
Parameters type and description
Parameter | Type | Description |
---|---|---|
*action | string | The PCMO action to control the flow of the call. |
*ws_url | string | The WebSocket URL where the audio stream will be sent. |
*listen_mode | string | Determines which part of the call audio is captured and stored
|
voice_quality | string | The desired voice quality in bits per second. Options are 8000, 16000. |
stream_on_answer | boolean | Whether to start streaming after the call is answered.The default value is false. |
Note
The stream()
method in the PiopiyAction
class sets up a WebSocket connection to transmit the call's audio in real time. This is ideal for scenarios such as real-time AI processing, interactive voice response (IVR) systems, or any application where live call audio needs to be analyzed or processed.
const {PiopiyAction} = require("piopiy");
const action = new PiopiyAction();
const ws_url = "ws://example.tcp.ngrok.url"
const options = { listen_mode: "caller", voice_quality: "8000", stream_on_answer: true }
action.stream( ws_url, options )
Parameters type and description
Mandatory parameters
Parameter | Type | Description |
---|---|---|
ws_url | string | The WebSocket URL provided by the ngrok TCP service. |
options | object | An object containing optional parameters (listen_mode). |
Options parameters
Parameter | Type | Description |
---|---|---|
listen_mode | string | Determines which part of the call audio is captured and stored
|
voice_quality | string | The desired voice quality in bits per second. Options are 8000, 16000. |
stream_on_answer | boolean | Whether to start streaming after the call is answered. The default value is false. |
The stream()
method in the PiopiyAction
class sets up a WebSocket connection to transmit the call's audio in real time. This is ideal for scenarios such as real-time AI processing, interactive voice response (IVR) systems, or any application where live call audio needs to be analyzed or processed.
from piopiy import Action
action = Action()
ws_url = "ws://example.tcp.ngrok.url"
options = { listen_mode: "caller", voice_quality: "8000", stream_on_answer: true }
action.stream( ws_url, options )
Parameters type and description
Mandatory parameters
Parameter | Type | Description |
---|---|---|
ws_url | string | The WebSocket URL provided by the ngrok TCP service. |
options | object | An object containing optional parameters (listen_mode). |
Options parameters
Parameter | Type | Description |
---|---|---|
listen_mode | string | Determines which part of the call audio is captured and stored
|
voice_quality | string | The desired voice quality in bits per second. Options are 8000, 16000. |
stream_on_answer | boolean | Whether to start streaming after the call is answered.The default value is false. |