One edge case I’d be curious about is what happens when the audio route changes mid-session. For example, a user starts dictating through a Bluetooth headset, unplugs it halfway through a sentence, and the phone switches back to its built-in mic with a different sample rate.
On iOS, a route change can affect the sample rate and channel configuration, so it’s not just a microphone restart problem. How does transcribe_cpp handle that transition? Does it rebuild the capture pipeline while preserving the current utterance, or does it finalize the sentence and start a fresh one? That distinction matters quite a bit for hands-free transcription, especially during long sessions.
One thing I’d be careful about here is the timing of the final decode. Say the Bluetooth input is running at 16 kHz mono, and the route switches to the built-in mic at 44.1 kHz while the decoder still has unprocessed frames from the previous utterance. If the VAD and endpointer reset immediately, how do you make sure those buffered frames are actually decoded before the old state is discarded?
I’d probably treat the route change as a boundary between two audio segments: stop accepting frames from the old capture session, drain its pending audio through the existing resampling and decode path, emit a final result if there’s enough speech to recover, and only then reset the endpointing state for the new input. Otherwise, even if the ring buffer survives the switch, the sentence can still disappear because the decoder never gets a chance to finish it.