fix(voice): resume AudioContext to prevent suspended state blocking silence detection

This commit is contained in:
2026-04-07 22:54:41 -04:00
parent 56b687c9f4
commit 6e0c528126
@@ -22,6 +22,9 @@ export function useSilenceDetector(options: SilenceDetectorOptions = {}) {
function start(stream: MediaStream, onSilence: () => void): void {
stop()
audioCtx = new AudioContext()
// Some browsers start AudioContext in "suspended" state — resume so
// getByteFrequencyData returns real values instead of all zeros.
audioCtx.resume().catch(() => {})
const source = audioCtx.createMediaStreamSource(stream)
const analyser = audioCtx.createAnalyser()
analyser.fftSize = 256