A codec (coder decoder) is an algorithm that compresses audio data for efficient transmission and decompresses it for playback. In the world of Voice AI, codecs are omnipresent but largely invisible until something goes wrong. A poorly negotiated codec can turn a crisp AI voice into muffled, robotic sounding audio. An unnecessary transcoding step can add 100 ms of latency and compound audio artifacts. Understanding codecs from first principles is foundational for serious Voice AI engineering.
The codec decisions your system makes happen at the SDP negotiation stage of every SIP call, often within the first 200 ms before any audio has been exchanged. These decisions cascade through the entire audio path: they determine the bandwidth your media server consumes, the CPU cycles spent encoding and decoding, and critically, the frequency content that reaches your ASR engine. A mistake here is embedded in every single audio frame of every call.
Why Compression Exists: The Raw Numbers
Raw uncompressed audio in PCM (Pulse Code Modulation) format at telephone quality (8 kHz sample rate, 16 bit samples) requires 128 kbps of bandwidth. Wideband audio at 16 kHz requires 256 kbps. For a one minute call that is approximately 2 MB of data at narrowband and 4 MB at wideband. Multiply by millions of concurrent calls on the global telephone network and you understand immediately why compression exists.
Audio codecs exploit two types of redundancy in speech signals. Temporal redundancy means adjacent audio samples are highly correlated, so you can predict the next sample from the previous few and encode only the prediction error. Psychoacoustic redundancy means the human auditory system has limited resolution in certain frequency bands and at certain amplitude levels, so you can discard information the ear cannot detect anyway. Different codecs strike different tradeoffs between compression ratio, perceptual quality, computational complexity, and encoding delay.
G.711: The Indestructible Grandfather
G.711 is an ITU standard from 1972 that compresses PCM audio to 64 kbps using logarithmic companding, a technique that gives more quantization levels to quiet sounds, where the human ear is more sensitive, and fewer levels to loud sounds. It comes in two variants: mu law (used in North America and Japan) and A law (used in Europe, India, and most of the rest of the world). Both achieve the same two to one compression ratio from 128 kbps PCM to 64 kbps G.711.
G.711 dominates PSTN telephony for three reasons: it is mandated by the ITU as the reference codec for circuit switched voice networks, it has essentially zero encoding latency (it is implemented as a lookup table operation, not a complex algorithm), and it introduces no perceptible quality degradation relative to raw 8 kHz PCM. Every SIP phone, every VoIP gateway, every PBX ever built supports G.711. It is ubiquitous and reliable for its intended purpose.
G.722: The HD Voice Upgrade
G.722 doubles the audio bandwidth to 16 kHz (covering 50 Hz to 7,000 Hz instead of the 300 Hz to 3,400 Hz range of G.711) at the same or slightly lower bitrate of 48 to 64 kbps. The perceptual improvement is immediately obvious: consonants are sharper and more distinctive, voices are easier to tell apart, and background noise is easier to separate from the foreground speech. This matters enormously for ASR accuracy.
Modern 4G VoLTE calls between two smartphones often use G.722 or its successor EVS (Enhanced Voice Services), which is why mobile to mobile calls sound dramatically better than mobile to landline calls, as the landline end forces a downgrade to G.711 at the PSTN interconnect. For AI voice agents making or receiving VoLTE calls, detecting and preferring G.722 in SDP negotiation can improve transcription accuracy by 8 to 15% according to internal benchmarks.
Opus: The Modern Internet Standard
Opus (RFC 6716) was developed by Xiph.org and standardized by the IETF in 2012. It is the default codec in WebRTC and the best choice for browser based Voice AI applications. Opus is remarkable in its range: it covers 6 kbps (low bitrate narrowband) all the way to 510 kbps (lossless quality wideband audio), adapts dynamically to changing network conditions, handles both speech and music gracefully, and has an algorithmic latency of just 2.5 ms. Unlike older proprietary formats, Opus is completely royalty free.
- G.711 mu/A law: 64 kbps, 8 kHz, PSTN standard, zero latency, universal support
- G.722: 48 to 64 kbps, 16 kHz, HD Voice, VoLTE, major ASR accuracy boost
- G.729: 8 kbps, 8 kHz, Low bandwidth but 10 ms codec delay, licensed patent
- Opus: 6 to 510 kbps, up to 48 kHz, WebRTC standard, royalty free, adaptive
- EVS: 5.9 to 128 kbps, up to 32 kHz, 5G and VoLTE, super wideband quality
- AMR WB: 6.6 to 23.85 kbps, 16 kHz, Common on 3G and 4G mobile calls in India
Transcoding: The Silent Quality Killer
Transcoding happens when audio is converted from one codec to another mid call. Each transcode is a lossy decode then encode cycle: you decompress the audio back to PCM, then recompress it with a different algorithm. Each step introduces the compression artifacts of that codec. A call that travels from caller phone G.711 to CPaaS internal Opus, then to your media server G.711, and finally to your ASR engine PCM has been transcoded multiple times. Quality degrades at each step, and 10 to 20 ms of latency is added per transcode.
The best Voice AI architectures minimize transcoding by negotiating a single codec end to end and performing exactly one final decode to PCM for the ASR engine. If your CPaaS delivers G.711 audio, pass G.711 directly to your ASR rather than converting to Opus first. This is a simple optimization that many early Voice AI implementations miss, often because default configurations introduce unnecessary codec conversions.
Codecs and Regional Connectivity
For Voice AI targeting Indian SMBs, many of which are located in areas with congested 3G networks or intermittent 4G coverage, codec choice has real business consequences. A G.711 stream at 64 kbps is more susceptible to packet loss than a G.729 stream at 8 kbps on a congested link. Opus at 12 to 16 kbps provides an excellent middle ground for internet telephony: low bandwidth, graceful packet loss concealment built in, and no licensing costs. For businesses operating voice agents that need to reach customers in Tier 2 and Tier 3 cities, testing your audio quality specifically on lower tier connections is where real world users are.
Frequently Asked Questions
What audio codec does PSTN use?
PSTN (Public Switched Telephone Network) primarily uses the G.711 codec, either A law (used in India and Europe) or mu law (used in North America and Japan). G.711 encodes audio at 64 kbps with 8 kHz sample rate and is the ITU standard for circuit switched voice.
What is the difference between G.711 and G.722?
G.711 is narrowband audio (8 kHz, 300 to 3400 Hz frequency range) at 64 kbps. G.722 is HD Voice (16 kHz, 50 to 7000 Hz) at 48 to 64 kbps. G.722 dramatically improves voice clarity and ASR accuracy. VoLTE calls on 4G networks often use G.722 automatically.
Which codec is best for AI voice agents?
For PSTN telephony, G.711 A law is standard and unavoidable. For internet based voice AI (WebRTC, browser), Opus is the best choice: it is royalty free, adaptive, and covers 6 kbps to 510 kbps. For Indian networks with packet loss, Opus at 12 to 16 kbps outperforms G.711 in resilience.
What is codec transcoding and why is it bad for voice AI?
Transcoding is converting audio from one codec to another mid call. Each transcode is lossy, degrading audio quality and adding 10 to 20 ms latency. Minimizing transcoding by negotiating a single end to end codec is a key Voice AI optimization.
