Latest Legacy

The audio Stream object

The audio Steam object lets you receive the raw audio of a live phone call over a configured WebSocket in near real time.

Attributes

Service_urlstringrequired

WebSocket URL to which the audio stream is to be initiated.

Example: wss://mystream.ngrok.io/audiostream

If a qualified URL is not present, or an active stream is already supplied to the URL, a 400 error is returned.

bidirectionalboolean

Specifies whether the audio being streamed over the WebSocket is bidirectional (the service can both read and write audio over the WebSocket) or one-way (read-only).

If the bidirectional attribute is set to true, then Plivo accepts the below parameters to accept the audio stream from your application over the WebSockets.

 

Allowed values:

event: Takes playAudio as the value
media: Takes a JSON input of the key values below
contentType: raw, wav
sampleRate: 8000 and 16000
payload: Base64-encoded raw audio
audio_trackstring

The audio track (inbound or outbound) of the underlying call that Plivo will fork and stream to the WebSocket service.

Allowed values: inbound (only audio received by Plivo from call participants is streamed over WebSocket), outbound (only audio transmitted by Plivo to call participants is streamed over WebSocket), both(both the audio streams received and transmitted by Plivo are streamed over WebSocket) Default is inbound

Note: When the bidirectional value is set to true, the audio_track value should not be set to outbound or both.
stream_timeoutinteger

The maximum duration, in seconds, for which audio will be streamed once streaming starts. At the end of the specified duration, streaming will stop. The stream timeout has no impact on the rest of the call flow. Must be a positive integer if provided. Defaults to 86,400 (24 hours).

status_callback_urlstring

URL notified by Plivo when one of the following events occurs:

  • audio stream is connected and audio begins streaming (first packet is sent)
  • audio stream is stopped intentionally
  • audio stream timeout is reached
  • audio stream failed to connect or got disconnected for any reason during an ongoing call

status_callback_methodstring

The HTTP verb used to invoke the status_callback_url.

Allowed values: GET, POST Defaults to POST.

content_typestring

Preferred audio codec and sampling rate.

Allowed values: audio/x-l16;rate=8000, audio/x-l16;rate=16000, audio/x-mulaw;rate=8000 Defaults to audio/x-l16;rate=8000.

extra_headersstring

Key-value pairs passed to the WebSocket service along with the audio stream. These extra headers will be passed with every HTTP request made by the call.

Takes a string of key-value pairs as input. Example: “test1=12,test2=123”. Total length of the string being passed should be no more than 512 bytes.
Only [A-Z], [a-z], and [0-9] characters are allowed in both key and value.

Response

{
    "api_id": "f7615566-13c5-11ee-b552-0242ac110005",
    "audio_track": "both",
    "bidirectional": false,
    "bill_duration": 27,
    "billed_amount": "0.00300",
    "call_uuid": "78737f83-4660-490d-98e1-025dfe4b5c8f",
    "created_at": "2023-06-21 13:23:44.136962+00:00",
    "end_time": "2023-06-21 18:53:43+05:30",
    "plivo_auth_id": "MAY2RJNZKZNJMWOXXX",
    "resource_uri": "/v1/Account/MAY2RJNZKZNJMWOXXX/Call/78737f83-4660-490d-98e1-025dfe4b5c8f/Stream/20170ada-f610-433b-8758-c02a2aab3662/",
    "rounded_bill_duration": 60,
    "service_url": "wss://mysocket.com/wss/v2/1/demo/",
    "start_time": "2023-06-21 18:53:16+05:30",
    "stream_id": "20170ada-f610-433b-8758-c02a2aab3662"
}