Prepare input that the service can actually interpret.
1. Permission lifecycle
Ask for microphone access at the point of use and explain the feature. Handle denial and revocation without repeatedly prompting. Make recording visible and stop when the session no longer needs input.
2. Encoding contract
Match required PCM encoding, sample rate and channel count. A byte buffer without a declared format is ambiguous. Resample deliberately where needed rather than relabeling bytes.
3. Backpressure
Audio capture can outpace network sending. Bound the queue and define overload behavior. Avoid buffering minutes of stale speech that will be transmitted after connectivity returns.
Worked scenario
A device captures stereo audio at a rate different from the model input requirement. Sending it as mono at the expected rate changes timing and intelligibility.
Apply it
Record a short local sample, inspect its format, and test a bounded capture-to-send queue under a slow fake sender.
Check your understanding
You can state the exact format of every audio buffer at the transport boundary. Explain the decision and show evidence from your implementation or design. If you cannot demonstrate it yet, revisit the relevant section before continuing.