What is WebRTC?

Definition

WebRTC is a set of web standards and protocols that let browsers and apps send real-time audio, video and data directly between devices. It handles encryption, network traversal and media transport.

Read the full guide: WebRTC vs WebSocket for real-time voice AI

How WebRTC works

WebRTC is two sets of specifications: a JavaScript API from the W3C, and a group of protocols from the IETF that RFC 8825 gives an overview of. Together they let a page capture a microphone, set up a connection, and send audio over it.

Setting up a connection takes three parts. Signaling is how the two sides exchange offers and answers, and WebRTC leaves it to the application, so each app uses its own server. ICE finds a network path between the two sides, including through home routers and firewalls, using helper servers called STUN and TURN when a direct path is blocked. Media then flows over UDP, encrypted with DTLS and SRTP, and carries audio coded with Opus. RFC 7874 requires WebRTC endpoints to support Opus and G.711.

Browsers add features that matter for voice: echo cancellation, noise suppression and automatic gain control, applied to the microphone before it is sent. They also adapt to packet loss and jitter without the application doing anything.

Why it matters for voice agents

A voice agent reaches callers in two ways. Phone calls arrive over the PSTN and a SIP trunk, with narrow telephony audio. Calls from a website or mobile app can use WebRTC and keep wideband audio, which helps recognition and sounds better.

The tradeoff is operational. WebRTC runs over UDP and recovers from loss without waiting, which suits low latency, but it needs signaling and often TURN servers, which cost money and add moving parts. A WebSocket carries audio over TCP, which is simpler to build and can stall when packets are lost. The guide compares them in detail.

A voice agent in an app also does not receive a phone number, so caller ID and number-based routing do not apply. The app identifies the user instead.

Example

An illustrative setup: a support page has a Talk to us button. Clicking it asks for microphone permission, opens a WebRTC connection to the agent’s server, and streams 48 kHz Opus audio both ways. The same agent also answers the company’s phone number over a SIP trunk at 8 kHz.

Guides

Sources

Get started today

Talk to an expert.

Connect with a member of our team and learn how Cartesia can help you build world-class voice experiences.

Contact Sales

Start building.

Access our models via API and bring a voice agent into production in minutes.

Try Cartesia