By Sagar Shankaran, Founder of CallSphere
Android's AudioRecord API is the lowest-level mic access for AI voice apps. Here is how to configure it for 16 kHz PCM, hardware AEC, and sub-300 ms streaming.
Key takeaways
If you bypass WebRTC and stream raw PCM directly to a Realtime API, AudioRecord is the API you reach for. With the right config (VOICE_COMMUNICATION source, 16 kHz mono, hardware AEC) you can hit sub-300 ms first-byte latency on a mid-range Android.
For AI voice agents that target an OpenAI Realtime, Gemini Live, or similar streaming endpoint with their own protocol, WebRTC is overkill. The path WebRTC.ventures used in their February 2026 Voice AI Android prototype: AudioRecord + WebSockets directly to a Python backend that proxied Gemini 2.0. Audio is captured as mono PCM at 16 kHz, 16-bit, with hardware AEC enabled — the canonical input format for streaming voice models.
This pattern is materially simpler than full WebRTC: no SDP, no ICE, no SFU, no DTLS-SRTP. The trade-off is that you handle reconnection, jitter buffering, and codec negotiation yourself. For one-to-one user-to-AI voice, that is often a good trade.
```mermaid flowchart LR Mic[Mic] --> AudioRecord[AudioRecord MediaRecorder.AudioSource.VOICE_COMMUNICATION] AudioRecord --> Buffer[ByteBuffer 16kHz mono PCM] Buffer --> WS[WebSocket] WS --> Backend[Realtime API Proxy] Backend --> AudioTrack[AudioTrack playback] AudioTrack --> Speaker[Speaker] ```
CallSphere's mobile clients use AudioRecord in two specific places, while WebRTC handles the rest:
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
37 agents · 90+ tools · 115+ DB tables · 6 verticals · HIPAA + SOC 2 · $149/$499/$1499 · 14-day /trial · 22% affiliate at /affiliate.
```kotlin import android.media.AudioFormat import android.media.AudioRecord import android.media.MediaRecorder
class VoiceStreamer { private val sampleRate = 16_000 private val channelConfig = AudioFormat.CHANNEL_IN_MONO private val audioFormat = AudioFormat.ENCODING_PCM_16BIT private val bufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat) * 2
private val recorder = AudioRecord( MediaRecorder.AudioSource.VOICE_COMMUNICATION, // hardware AEC sampleRate, channelConfig, audioFormat, bufferSize )
fun start(socket: WebSocket) { recorder.startRecording() Thread { val buf = ByteArray(bufferSize) while (!Thread.interrupted()) { val read = recorder.read(buf, 0, buf.size) if (read > 0) socket.send(buf.copyOf(read).toByteString()) } }.start() } } ```
```xml
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Is AudioRecord faster than WebRTC? First-byte latency: yes, by 50-100 ms. End-to-end: depends on backend.
Does it support echo cancellation on cheap phones? Hardware AEC quality varies; pair with a software AEC fallback.
Can I use it with WebRTC? No — WebRTC owns the mic via its own AudioDeviceModule; you can have only one.
Does it work in the background? Only inside a foreground service of type `microphone` on Android 14+.
What sample rate should I use? 16 kHz for Gemini Live, 24 kHz for OpenAI Realtime, 48 kHz for music or non-voice.
Try CallSphere voice agents at /demo, see /pricing, or start a /trial.
Written by
Sagar Shankaran· Founder, CallSphere
Sagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
A founder's guide to texto a voz (text-to-speech in Spanish): LATAM vs Castilian voices, free options, and how CallSphere ships Spanish agents.
A founder's guide to the female voice generator landscape: AI female voices, Japanese voices, robot voices, and how CallSphere ships 57+ voices live.
A founder's guide to the Siri voice generator landscape: how AI voice cloning works, what is legal, and how CallSphere uses 57+ voices in production.
A founder's guide to AI voice assistants for ecommerce: customer service, order lookup, and how CallSphere fits in versus virtual receptionists.
Robot text to speech in 2026: how I pick TTS APIs, when robotic voices help, and how CallSphere ships 57+ language voice agents. Hands-on guide.
The customer support specialist role in 2026 is half human, half AI. Here is what the job looks like, the AI tools that pair with it, and how we ship it.
© 2026 CallSphere LLC. All rights reserved.