Voice Media Stream
The media stream API provides access to the raw audio of your voice calls by forking the audio stream in real-time and sending it to a destination of your choice using a web socket. The forked audio streams can be used to improve customer experience in real-time applications like transcription, speech analytics, voice authentication, and so on.
The media stream API is initiated on a bridged call when a user wants to fork the raw audio of the voice call.
Start Media Stream API
- API Route:
https://api.enablex.io/voice/v1/call/$callId/stream
- Method: PUT
Sample Request
PUT https://api.enablex.io/voice/v1/call/$callId/streamAuthorization: Basic xxxxxxContent-Type: application/json{ "stream_dest": "websocket ip:websocket port"}
Note: Embedded $callId on API Endpoint URL.
Explanation of JSON Payload
Key | Description |
---|---|
stream_dest | Destination Server IP & Port for Websocket Connection |
Sample Responses
HTTPS: 201{"voice_id":"95971e57-e4e3-4045-9cd8-a1350e66a36c","from":"12028528186","to":"919972972207","state":"initiated","timestamp":"2021-06-21T06:42:03.147Z"}
Sample Error Response
HTTPS: 500 Internal Server Error{"voice_id":"95971e57-e4e3-4045-9cd8-a1350e66a36c","from":"12028528186","to":"919972972207","state":"failed","timestamp":"2021-06-21T06:42:03.147Z"}
Sample Error Response
HTTPS: 404{"result": 6110,"msg": "Application not found"}
Stop Media Stream
- API Route:
https://api.enablex.io/voice/v1/call/$callId/stream
- Method: DELETE
Sample Request
DELETE https://api.enablex.io/voice/v1/call/$callId/streamAuthorization: Basic xxxxxxContent-Type: application/json
Note: Embedded $callId on API Endpoint URL.
Error Responses
HTTPS: 201{"voice_id": "7f0750f5-a6b5-4715-bacf-2b439718fbf4","state": "success","timestamp": "2021-06-28T12:16:08.578Z"}
Error Responses
HTTPS: 404{"result": 6110,"msg": "Application not found"}
Webhook Events
{"voice_id":"71fef22b-a61b-4a03-b58f-c46e388afac3","from":"12028528186","to":"919972972207","timestamp":"2021-06-21T06:59:40.653Z","state":"stream_started"}
Explaination of JSON Payload
Object/Key | Description |
---|---|
voice_id | A unique identifier of every voice call. |
from | The number from which the call is initiated. |
to | The number of the recipient. |
timestamp | The date and time of placing the call. |
state | The state of streaming. It can be represented as stream_initiated, stream_started, stream_stopped, or stream_failed. |