Audio Streaming for voice AI agents
Live call audio in, synthesized speech back, over one WebSocket. You own the AI pipeline; Plivo handles the phone network. Works best with Pipecat.
- edge → your server
- ~50ms
- countries
- 190+
- uptime
- 99.99%
A visualization of Plivo audio streaming. Caller audio arrives over a WebSocket as 20 millisecond mu-law frames on the caller trace, and the agent's reply streams back as playAudio on the agent trace. Responses land in under a second.
One WebSocket between your call and your AI
Audio streaming exposes the raw audio of a live call over a WebSocket, in both directions, so your agent can listen and respond in the same moment.
Caller
A caller dials your Plivo number, or you place an outbound call through the Voice API.
Plivo Voice
Plivo answers, fetches your Stream XML from your Answer URL, and opens a secure WebSocket to your server.
Your server
You receive 20 ms audio frames, run your logic, and stream synthesized audio back.
AI services
Any provider you choose transcribes, reasons, and speaks, with barge-in support.
From dial tone to dialogue in two steps
One server, two endpoints. The Stream SDK takes care of the framing, encoding, and events.
- 01
/answerreturns your<Stream>XML when Plivo picks up. - 02
/streamreceives caller audio and streams your agent's reply back.
from fastapi import FastAPI, WebSocket
from fastapi.responses import Response
from plivo_stream import PlivoFastAPIStreamingHandler
app = FastAPI()
ANSWER_XML = """<Response><Stream bidirectional="true" keepCallAlive="true"
contentType="audio/x-mulaw;rate=8000">wss://your-server.com/stream</Stream></Response>"""
@app.get("/answer")
def answer(): # Plivo requests this on pickup
return Response(ANSWER_XML, media_type="application/xml")
@app.websocket("/stream")
async def stream(websocket: WebSocket): # Plivo opens the socket here
handler = PlivoFastAPIStreamingHandler(websocket)
@handler.on_media
async def on_media(event):
audio = event.get_raw_media() # caller audio (mu-law)
reply = await run_ai_pipeline(audio) # your STT -> LLM -> TTS
await handler.send_media(reply) # speak back to the caller
await handler.start() import express from 'express';
import { createServer } from 'http';
import { PlivoWebSocketServer } from '@plivo/plivo-stream-sdk';
const app = express();
const ANSWER_XML = `<Response><Stream bidirectional="true" keepCallAlive="true"
contentType="audio/x-mulaw;rate=8000">wss://your-server.com/stream</Stream></Response>`;
app.get('/answer', (req, res) => // Plivo requests this on pickup
res.type('application/xml').send(ANSWER_XML));
const server = createServer(app);
const plivo = new PlivoWebSocketServer({ server, path: '/stream' });
plivo.onMedia(async (event, ws) => {
const audio = event.getRawMedia(); // caller audio (mu-law)
const reply = await runAiPipeline(audio); // your STT -> LLM -> TTS
plivo.playAudio(ws, 'audio/x-mulaw', 8000, reply); // speak back
});
server.listen(5000); Ship faster on Pipecat
Plivo streams live call audio straight into your Pipecat pipeline over WebSocket. Start from a working voice agent, not telephony plumbing.
- Native PlivoFrameSerializer in Pipecat core
- Bring any STT, LLM, and TTS, or go speech-to-speech
- Scaffold in one command with the Pipecat CLI
# scaffold a phone agent on Plivo telephony
uv tool install "pipecat-ai[cli]"
pipecat init call-bot --bot-type telephony --transport plivo \
--mode cascade --stt deepgram_stt --llm openai_llm --tts cartesia_tts
cd call-bot && uv sync
uv run bot.py # expose with: ngrok http 7860 from pipecat.pipeline.pipeline import Pipeline
from pipecat.serializers.plivo import PlivoFrameSerializer
from pipecat.transports.websocket.fastapi import (
FastAPIWebsocketParams, FastAPIWebsocketTransport)
transport = FastAPIWebsocketTransport(websocket, FastAPIWebsocketParams(
audio_in_enabled=True, audio_out_enabled=True, add_wav_header=False,
serializer=PlivoFrameSerializer(stream_id, call_id,
auth_id=os.environ["PLIVO_AUTH_ID"],
auth_token=os.environ["PLIVO_AUTH_TOKEN"])))
pipeline = Pipeline([
transport.input(), # caller audio in from Plivo
stt, # Deepgram
user_aggregator,
llm, # OpenAI
tts, # Cartesia
transport.output(), # agent audio back to the caller
assistant_aggregator,
])
worker = PipelineWorker(pipeline, params=PipelineParams(
audio_in_sample_rate=8000, audio_out_sample_rate=8000))
await runner.add_workers(worker)
await runner.run() Everything a production voice agent needs from its carrier
The platform handles the hard telephony work: codecs, interruption, security, and the full stream lifecycle. You focus on the conversation.
Bidirectional WebSocket
Receive caller audio and send synthesized speech back over a single connection, so your agent can listen and talk at the same time.
Barge-in and interruption
Clear the playback queue the instant a caller speaks with clearAudio, and track exactly what finished playing with checkpoints.
In-stream DTMF, both ways
Receive keypad presses as dtmf events mid-stream, and send digits out when your agent has to drive an IVR or answering machine.
Edge-routed by design
Plivo answers calls at the edge location closest to the caller, so co-locating your server keeps the network hop short and the conversation snappy.
Noise cancellation & BVC
Filter background noise and background voices on the wire, tunable per stream, so your speech-to-text hears only the caller.
Native telephony codec
Stream μ-law 8 kHz, the phone network's own format, or switch to 16-bit Linear PCM at 8 or 16 kHz when your STT model wants wideband audio.
Lifecycle callbacks
Subscribe to started, stopped, and failed webhooks with duration and status reason to power monitoring, billing, and retries.
Session metadata
Pass user, session, or tenant context into the start event with extraHeaders, so every stream lands on your server already identified.
Signed connections
Every WebSocket upgrade carries a V3 HMAC-SHA256 signature you can validate with the SDK, over wss and TLS, so only Plivo traffic reaches your server.
Stream one way to listen, both ways to converse
One XML attribute sets the direction. Each direction unlocks a different class of product.
Both ways to converse
bidirectional-
Voice assistants
Agents that answer, qualify, and resolve on their own.
-
Voice bots & smart IVR
Replace press-one menus with intent-aware routing.
-
Outbound conversations
Reminders and follow-ups that handle questions live.
bidirectional=truekeepCallAliveclearAudio One way to listen
listen-only-
Real-time transcription
Live captions and searchable transcripts as words are spoken.
-
Sentiment & QA
Score tone, intent, and compliance while the call happens.
-
Agent assist & co-pilot
Surface answers to human agents mid-call.
audioTrack=both Bring your own AI. Plivo moves the audio.
Audio streaming is model-agnostic on purpose. Swap any provider without touching the call layer, so you are never locked into one vendor's voices or models.
Transcribe
Forward caller audio to any streaming STT model to turn speech into text as it is spoken.
- Deepgram
- AssemblyAI
- Sarvam
Think
Send the transcript to any LLM to decide what to say next, call tools, or look up your knowledge base.
- OpenAI
- Anthropic
- Google Gemini
Speak
Synthesize the reply with any TTS voice and stream it back to the caller for a natural response.
- ElevenLabs
- Cartesia
- Inworld
Engineered for the sub-second budget
Wherever you build, Plivo has a point of presence close to your callers. Calls enter the network at the nearest edge and reach your server in about 50 ms, so the sub-second budget is yours to spend on AI.
A point of presence near every caller
Plivo answers at the edge closest to the caller, wherever that is. Run your WebSocket server and model endpoints in the matching region and the whole turn stays inside the sub-second budget.
- US traffic US East (Virginia) or US West (Oregon)
- Europe Frankfurt or London
- Asia-Pacific Singapore or Mumbai
- Global Multi-region with geographic routing
Enterprise-grade security
& compliance
- tls · aes-256
Encryption everywhere
TLS in transit. AES-256 at rest. No exceptions.
- us · eu · apac
Data residency
Choose US, EU, or APAC. Your data stays where you need it.
- logs · rbac · reports
Audit-ready
Full access logs, RBAC, and compliance reports on demand.
Put your agent on the phone network
Start streaming live call audio in minutes. Free credits, no credit card required.