pcm-stream
Optional raw PCM streaming helpers, imported from react-native-waveform-recorder/pcm-stream.
This entry point is opt-in: apps that don't import it don't ship it. The main view already declares enablePcmStream and onPcmChunk; the helpers below make the base64 payload easy to consume.
Usage
tsx
import {
WaveformRecorderView,
} from 'react-native-waveform-recorder';
import {
decodePcmChunk,
pcmToMonoFloat32,
} from 'react-native-waveform-recorder/pcm-stream';
<WaveformRecorderView
output={{ format: 'wav', sampleRate: 16000, channels: 1 }}
enablePcmStream
pcmChunkMs={100}
onPcmChunk={(e) => {
const int16 = decodePcmChunk(e.chunk);
const float32 = pcmToMonoFloat32(int16, e.channels);
// feed `float32` into Whisper / VAD / your STT pipeline of choice.
}}
/>Caveats
- Streaming only works with
output.format = 'wav'. The m4a / opus paths don't hand us pre-encoded samples. - Payloads cross the bridge as base64 strings, not zero-copy buffers. For multi-MB/s pipelines, prefer react-native-audio-api.