expo-audio: Add real-time PCM buffer streaming support for microphone recording
O
Ojoawo Joshua
Summary
expo-audio currently lacks the ability to stream raw PCM buffers from the
microphone in real-time. This is a critical missing feature for use cases
like live speech recognition, audio analysis, waveform visualization, and
WebSocket audio streaming.
Current Behavior
expo-audio supports basic recording and playback, and provides PCM samples
for playback visualization — but there is no way to receive a continuous
stream of raw PCB buffers from the microphone during recording.
Expected Behavior
Developers should be able to receive a real-time callback with raw PCM
Float32Array buffers as audio is being captured from the microphone.
Proposed API
const { startRecording, stopRecording } = useAudioRecorder({
sampleRate: 16000,
channels: 1,
onPCMData: (buffer: Float32Array, sampleRate: number) => {
// send to WebSocket, run through ML model, visualize waveform, etc.
}
});
Proof of Demand
I built and published expo-audio-stream-pcm
(https://www.npmjs.com/package/expo-audio-stream-pcm) specifically to fill
this gap. The library already has a working native implementation in Kotlin
(Android) that delivers real-time PCM buffers via a callback.
Other community packages solving the same problem:
- @siteed/expo-audio-studio
- expo-audio-stream (mykin-ai)
- @speechmatics/expo-two-way-audio
The existence of multiple community packages solving the same problem is
strong evidence this belongs in the official SDK.
Use Cases
- Live speech-to-text (OpenAI Whisper, Google Speech, etc.)
- Real-time audio waveform visualization
- WebSocket audio streaming to a backend
- On-device ML audio analysis
Willingness to Contribute
I am willing to submit a PR implementing this feature, porting my existing
Kotlin implementation into expo-audio and adding the corresponding iOS
(Swift) implementation to match.