fix(voice): resume AudioContext to prevent suspended state blocking silence detection
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user