---
title: "G.711 vs Opus vs G.722: Best Codec for Voice AI | Vobiz"
description: "G.711 vs Opus vs G.722 for voice AI: how 8 kHz vs 16 kHz audio affects speech recognition and TTS, what reaches the PSTN, and which format to stream."
canonical: https://www.vobiz.ai/resources/blogs/developers-guides/voice-codecs-for-voice-ai/
---
[Blogs](https://www.vobiz.ai/resources/blogs/)Developer's Guides

# G.711 vs Opus vs G.722: Best Codec for Voice AI Agents in 2026

Sample rates, bitrates and narrowband vs wideband for AI voice agents, what really reaches the PSTN in India, and which audio format to stream for STT and TTS.

![G.711 vs Opus vs G.722: Best Codec for Voice AI Agents in 2026](https://www.vobiz.ai/blog-thumbs/voice-codecs-for-voice-ai.jpg)

![Team Vobiz](https://www.vobiz.ai/favicon-192.png)Team Vobiz

10 min read19 November 2026

Share this article

On this page

Subscribe

For newsletter and updates

For an AI voice agent answering ordinary phone calls, the best codec is usually the one the phone leg already uses: G.711 at 8 kHz, passed to your speech-to-text without extra resampling or transcoding. Wideband codecs such as G.722, Opus and AMR-WB do give speech recognition and text-to-speech more to work with, but only when every hop of the call stays wideband, which today mostly means SIP, WebRTC and in-app calls rather than PSTN calls. This guide compares G.711 vs G.722 vs Opus for voice AI, explains what 8 kHz vs 16 kHz means for speech recognition, and gives a format choice for each common setup.

## What a codec decides in a voice AI call

For a human listener, the codec decides whether a call sounds "phone-like" or "HD". For a voice agent it decides three things:

-   **How much of the voice your STT model hears.** A narrowband codec throws away everything above about 3.4 kHz before your model sees a single sample.
-   **How your TTS voice sounds to the caller.** A voice rendered at 24 kHz is cut down to the bandwidth of the phone leg, whatever you send.
-   **How many conversions sit in the audio path.** Every decode, resample and re-encode costs a little CPU, a little delay and a little quality.

The codec is negotiated per call leg in SDP, so one call can use AMR-WB on the caller's handset, G.711 to the carrier and something else again to your media server. What your agent hears is limited by the narrowest leg.

## G.711 vs G.722 vs Opus vs AMR-WB: comparison table

| Codec | Sampling rate | Audio band | Bitrate | Where you meet it | For voice AI |
| --- | --- | --- | --- | --- | --- |
| **G.711** (PCMU μ-law, PCMA A-law) | 8 kHz | ~300 to 3,400 Hz (narrowband) | 64 kbps | PSTN interconnects, SIP trunks, almost every PBX | The common ground. Little processing, universally accepted by STT and TTS providers |
| **G.722** | 16 kHz | 50 to 7,000 Hz (wideband) | 48, 56 or 64 kbps (64 in practice) | IP desk phones, PBXs, some SIP trunks | Wideband at the same bitrate as G.711, only when both ends support it |
| **Opus** | 8 to 48 kHz | Narrowband (4 kHz) up to fullband (20 kHz) | 6 to 510 kbps, adaptive | WebRTC, browsers, mobile apps, some SIP platforms | Best for app and browser legs. Has in-band FEC for packet loss. Cannot cross the PSTN as-is |
| **AMR-WB** | 16 kHz | 50 to 7,000 Hz | 6.6 to 23.85 kbps | VoLTE "HD voice" on mobile networks | You rarely touch it directly. Usually converted at the carrier edge |
| **EVS** | 8, 16, 32 or 48 kHz input | Narrowband up to fullband | 5.9 to 128 kbps | Newer VoLTE and VoNR networks | Same as AMR-WB: lives inside the mobile network |

Bitrate is not quality: G.711 and G.722 both run at 64 kbps, but G.722 carries roughly twice the audio band.

### G.711: PCMU vs PCMA

G.711 samples at 8 kHz with 8 bits per sample, which gives 64 kbps. It comes in two flavours that differ only in the companding curve: μ-law (PCMU) is used mainly in North America and Japan, and A-law (PCMA) in most other countries. A 20 ms frame is 160 bytes of either.

G.711 needs very little processing and nearly every STT and TTS provider accepts it natively. Its limit is the band: anything above about 3.4 kHz is gone.

### G.722: wideband at the same bitrate

G.722 samples at 16 kHz and keeps 50 to 7,000 Hz, which is where much of the difference between "s", "f" and "th" lives. It runs at 64 kbps like G.711, so bandwidth is not the reason to avoid it. Support is: both ends of the leg have to offer it, and any hop that falls back to G.711 removes the benefit.

One well-known trap: the RTP clock rate for G.722 is 8,000 Hz even though the audio is sampled at 16,000 Hz. RFC 3551 calls this an error inherited from RFC 1890 that must stay for backward compatibility. If you write your own RTP handling, timestamps advance at 8 kHz while your decoder runs at 16 kHz.

### Opus: adaptive, built for the internet

Opus scales from 6 kbps narrowband speech to 510 kbps stereo music, with frame sizes from 2.5 to 60 ms and in-band forward error correction. It is the codec you get between a browser or app and a media server, and it copes well with lossy mobile networks. If your agent talks to users through a web widget or a mobile app, Opus end to end is the right answer.

What Opus cannot do is reach a phone number unchanged: it is transcoded, usually to G.711, where the call enters the telephone network.

## What actually reaches the PSTN, especially in India

Assume narrowband. The "HD" icon on a VoLTE call usually means AMR-WB, and newer networks add EVS, but these codecs live inside the mobile operator's network. In India, VoLTE HD voice has worked within a single operator's network, while cross-network calls have usually fallen back to narrowband. TelecomTalk reported in November 2025 that users were seeing HD indicators on some Jio to Airtel calls, but noted that neither operator had confirmed a rollout. The IETF's RFC 7875 states the general point plainly: if G.711 is used as a fallback for interoperation, wideband voice quality is lost.

For a voice agent, the leg that matters is the one between the carrier and your platform. On a real PSTN call documented in Vobiz's Gemini Live integration guide, the call detail record shows the negotiated codec as PCMU. That is the typical case for business numbers today.

Two practical consequences:

1.  **A 16 kHz or 24 kHz stream from a PSTN call still carries narrowband content.** Vobiz's own docs put it directly: a higher declared rate does not convert or improve audio by itself.
2.  **Check, don't guess.** Every Vobiz call detail record has a `codec` field next to `mos`, `jitter` and `packet_loss`, so you can see what each call actually negotiated.

## 8 kHz vs 16 kHz speech recognition

Wideband audio helps speech recognition. Google Cloud's Speech-to-Text best practices say to capture audio at 16,000 Hz or higher where you can. The same page adds the part people skip: if the source is at a lower native rate, set the sample rate to match it instead of resampling, and it gives telephony at 8,000 Hz as the example. It also lists μ-law and A-law among lossy codecs that may reduce accuracy, and recommends lossless formats such as LINEAR16 where you control the capture.

Put together, for phone calls:

-   **Upsampling 8 kHz to 16 kHz adds no information.** The frequencies above 4 kHz were removed by the codec and cannot be recovered. You get a bigger stream and an extra conversion.
-   **Use a model trained on telephone audio when your audio is telephone audio.** Deepgram, for example, lists `phonecall` variants (such as `nova-2-phonecall`) alongside its general models. Test them against your general model on your own recordings.
-   **Declare the format honestly.** Deepgram accepts `mulaw`, `alaw`, `linear16`, `opus`, `amr-wb` and others, and requires `sample_rate` whenever you set `encoding`. A mismatch between declared and actual format is one of the most common causes of empty or garbled transcripts.
-   **Know what your speech-to-speech model takes.** OpenAI's Realtime API accepts `audio/pcm` at 24 kHz only, or G.711 as `audio/pcmu` (μ-law) and `audio/pcma` (A-law). For a phone call, passing G.711 straight through avoids converting 8 kHz audio to 24 kHz for no gain.

We won't quote a word error rate gain for wideband audio; it depends on the model, language, accents and noise. If you have wideband callers, compare both rates on your own recordings.

## How codec choice affects TTS quality

Most TTS engines render at 22 to 24 kHz by default. Deepgram's streaming TTS, for instance, defaults to linear16 at 24,000 Hz but can also output `mulaw` or `alaw` at 8,000 Hz directly. On a narrowband phone leg the caller hears 300 to 3,400 Hz regardless, so a voice that sounded rich in a demo can sound thin on the phone.

What to do about it:

-   **Audition voices at 8 kHz.**
-   **Convert once.** Either ask the TTS provider for 8 kHz μ-law and send it as-is, or send its native linear PCM and let the telephony platform do a single downconversion. Avoid chains like 24 kHz to 16 kHz to 8 kHz to μ-law across three services.

## Transcoding: what it costs in latency and quality

Each transcoding step decodes, often resamples, then re-encodes. Individually these are cheap on modern CPUs. The costs add up in three ways:

-   **Quality.** RFC 7875 puts the loss from transcoding AMR-WB at roughly 0.2 to 0.3 MOS in most cases it studied, and notes that voice quality is significantly degraded by transcoding in general.
-   **Delay.** Codecs that work on frames add buffering and look-ahead at each step, and resamplers add a little more. RFC 7875 notes these delays are additive.

For a voice agent the delay matters most, because it sits directly in the turn-taking loop. We break down where the rest of the time goes in [why your voice AI sounds slow](https://www.vobiz.ai/resources/blogs/voiceai-infrastructure/why-voice-ai-sounds-slow/). Packet loss interacts with codec choice too: Opus has in-band FEC, while G.711 relies on the receiver's packet loss concealment. See [RTP jitter buffering and packet loss concealment](https://www.vobiz.ai/resources/blogs/developers-guides/rtp-jitter-mechanisms/) for how that works.

A quick audit: list every format your audio passes through in each direction. If there are more than two changes of codec or sample rate, there is usually one you can remove.

## What WebSocket audio streams send

If you build your own pipeline with a WebSocket media stream, you choose the format at the stream level. On Vobiz the options are:

| Direction | μ-law 8 kHz | L16 8 kHz | L16 16 kHz | L16 24 kHz |
| --- | --- | --- | --- | --- |
| Inbound (caller audio to your server) | Yes | Yes (default) | Yes | No |
| Outbound (`playAudio` to the caller) | Yes | Yes | Yes | Yes |

L16 is 16-bit linear PCM, mono. A 20 ms frame is 160 bytes in μ-law at 8 kHz, 320 bytes in L16 at 8 kHz and 640 bytes in L16 at 16 kHz. Two details catch people out: inbound L16 arrives big-endian (network byte order) while `playAudio` L16 must be little-endian, and the inbound format is reported in `start.mediaFormat`, which is what you should decode against.

Pick the format the next service in your pipeline expects. Outbound 24 kHz is useful when your TTS produces it natively, but it is still downconverted for a G.711 phone leg.

## Practical recommendation: which codec for which setup

| Setup | Phone or transport leg | Stream / model format | Why |
| --- | --- | --- | --- |
| PSTN calls to OpenAI Realtime | G.711 | μ-law 8 kHz in, `audio/pcmu` both ways | Zero conversions on your side |
| PSTN calls with Deepgram STT and streaming TTS | G.711 | μ-law 8 kHz (`encoding=mulaw`, `sample_rate=8000`), TTS `mulaw` 8 kHz | Native format end to end |
| PSTN calls with an STT that wants 16 kHz PCM | G.711 | L16 16 kHz in, L16 at your TTS rate out | One resample, done by the platform |
| SIP trunk into LiveKit, Vapi, Retell or similar | G.711 by default, wideband if both sides offer it | Negotiated in SDP | Let the platforms negotiate; G.711 is the safe common ground |
| Browser or mobile app users | Opus | Opus to your media server | Wideband and resilient to packet loss |

The short version:

1.  **On phone calls, design for 8 kHz.** Tune prompts, voices and STT models for narrowband audio, because that is what most callers will send you.
2.  **Don't upsample for the model's sake.** Use 16 kHz only when a downstream service needs it, and let one component do the conversion.
3.  **Use wideband where it actually exists.** App, browser and SIP desk phone users can get Opus or G.722 end to end, and that is where wideband helps STT and TTS.
4.  **Count your conversions** and remove the ones that add nothing.
5.  **Measure** the negotiated codec, MOS and transcription quality on your own calls before and after any change.

## How to set this up on Vobiz

**WebSocket streaming.** Set the inbound format on the `<Stream>` verb in your VobizXML answer:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Stream bidirectional="true" keepCallAlive="true"
          contentType="audio/x-mulaw;rate=8000">
    wss://your-server.example.com/ws
  </Stream>
</Response>
```

Change `contentType` to `audio/x-l16;rate=16000` if your STT expects 16 kHz linear PCM. Send `playAudio` in the format and rate your TTS actually produces, including L16 at 24 kHz.

**SIP trunking.** Vobiz [SIP trunks](https://www.vobiz.ai/products/sip-trunking/) connect to Airtel, Jio and VIL in India, and you can bring your own carrier. For BYOC trunks, Vobiz supports G.711 (PCMU and PCMA), G.729 and Opus, and configures the trunk to your codec preference order.

**Monitoring.** Each call detail record includes the negotiated `codec`, `mos`, `jitter` and `packet_loss`, so you can check codec behaviour per call instead of assuming it.

India calls are a flat ₹0.42/min inbound and outbound, billed in INR with a GST invoice; see [pricing](https://www.vobiz.ai/pricing/). The [Voice API](https://www.vobiz.ai/products/voice-api/) and [docs](https://www.vobiz.ai/docs/introduction) cover the stream events in full, and you can sign up at the [Vobiz console](https://console.vobiz.ai/) and have a first call live in about 10 minutes.

## FAQ

### Is Opus better than G.711 for voice AI?

On legs that can carry it, yes: Opus delivers wideband or better audio, adapts its bitrate and has in-band FEC. But a PSTN call is converted to G.711 at the carrier edge, so for phone calls the gain disappears. Use Opus for browser and app callers, and G.711 passthrough for phone callers.

### Does 16 kHz improve speech recognition on phone calls?

Only if the audio was wideband to begin with. G.711 phone audio has nothing above about 3.4 kHz, so resampling it to 16 kHz adds data but no information. Google's Speech-to-Text guidance is to use the native rate, commonly 8,000 Hz for telephony, rather than resample.

### What is the difference between G.722 and G.711?

Both run at 64 kbps. G.711 samples at 8 kHz and carries about 300 to 3,400 Hz. G.722 samples at 16 kHz and carries 50 to 7,000 Hz, so speech sounds fuller and consonants are clearer. G.722 only works when both ends of the leg support it.

### Do Indian phone calls support HD voice?

Within one mobile operator's VoLTE network, yes, using AMR-WB. Calls between operators have usually fallen back to narrowband, and there are only unconfirmed reports of cross-network HD between Jio and Airtel. For business numbers reaching a voice AI platform, plan for G.711 and check the codec field in your CDRs.

### What audio format should I send to OpenAI Realtime from a phone call?

Use G.711. The Realtime API accepts `audio/pcmu` and `audio/pcma` as well as 24 kHz `audio/pcm`. With a μ-law 8 kHz stream you can pass audio both ways without resampling.

## More Related Articles

[![Mechanisms to Improve RTP Jitter](https://www.vobiz.ai/blog6/thumbnail.jpg) Developer's Guides9 min read ### Mechanisms to Improve RTP Jitter Learn how carrier-grade voice platforms manage RTP jitter with adaptive buffering, packet loss concealment, FEC, and smart routing for smooth Voice AI calls. Read full article ![Vikash Srivastava](https://www.vobiz.ai/team%20photos/vikash.png)Vikash Srivastava 25 September 2026](https://www.vobiz.ai/resources/blogs/developers-guides/rtp-jitter-mechanisms/)[![The Complete Vobiz Developer Guide: From Signup to Your First Production Call (2026)](https://www.vobiz.ai/developerguidethumbnail.jpg) Developer's Guides11 min read ### The Complete Vobiz Developer Guide: From Signup to Your First Production Call (2026) Set up the Vobiz telephony API from signup to your first production call - auth, SIP trunking, AI voice integrations, SDKs, and MCP tooling. Read full article ![Ishani Singh](https://www.vobiz.ai/blogpromotion/ishani.png)Ishani Singh 10 August 2026](https://www.vobiz.ai/resources/guides/vobiz-developer-guide-api-setup-to-production/)[![How to Build a Production-Ready Outbound AI Calling Campaign on Vobiz in Under 10 Minutes](https://www.vobiz.ai/2306blog.jpg) Developer's Guides8 min read ### How to Build a Production-Ready Outbound AI Calling Campaign on Vobiz in Under 10 Minutes Launch a production-ready outbound AI calling campaign on Vobiz: provision DIDs, set up AMD, write call flow XML and sync hangup webhooks to your CRM. Read full article ![Ishani Singh](https://www.vobiz.ai/blogpromotion/ishani.png)Ishani Singh 23 June 2026](https://www.vobiz.ai/resources/guides/outbound-ai-calling-campaign/)
