Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(voice-runtime): keep quieter turns audible outside playback
muterCb06add658f46
diff --git a/apps/voice-runtime/AGENTS.md b/apps/voice-runtime/AGENTS.mdindex 0b7a6ed0..28092f1d 100644--- a/apps/voice-runtime/AGENTS.md+++ b/apps/voice-runtime/AGENTS.md@@ -34,5 +34,5 @@- Every track consumer attempt claims its transcript media epoch from TeamHub (`claimVoiceMediaEpoch`) and never counts epochs in memory: a job restarted mid-session (deploy, crash, key change) must not reuse an epoch whose coverage stream an earlier job started.- Backpressure is bounded. Failure must stop or reconnect the affected track instead of accumulating unbounded PCM.- Shutdown waits for accepted final/progress callbacks up to a fixed deadline and then exits non-zero if state is uncertain.-- The Live worker's local gate sends the microphone as silence unless Silero hears speech within `otherSpeakerDb` of the level it learned from the user on this track; quieter voices are other people in the room and neither reach the provider nor pause a reply.+- During reply playback, the Live worker's local gate sends the microphone as silence unless Silero hears speech within `otherSpeakerDb` of the level it learned on this track; quieter speech neither reaches the provider nor pauses a reply. Outside playback, Silero alone gates the microphone so a stale learned level cannot mute the user's next turn.- Never move recording back into the ASR job process; ASR load or failure must never stall the Capture recorder. A recorder never extends an epoch it did not start; TeamHub rejects the conflicting segment and the recorder reports failure.diff --git a/apps/voice-runtime/src/live-worker.test.ts b/apps/voice-runtime/src/live-worker.test.tsindex 7a2ea030..7ea0659a 100644--- a/apps/voice-runtime/src/live-worker.test.ts+++ b/apps/voice-runtime/src/live-worker.test.ts@@ -317,12 +317,12 @@ async function harness(return {async pushPCM(frame: Int16Array) {through += 512;- // 1 is the user's speech, 3 someone speaking farther away.+ // 1 is loud speech; 3 is speech 15 dB quieter.return [{throughSample: through,speech: frame[0] === 1 || frame[0] === 3,- levelDb: frame[0] === 3 ? -45 : -20,+ levelDb: frame[0] === 3 ? -35 : -20,},];},@@ -1065,6 +1065,31 @@ describe("LiveVoiceWorker", () => {await test.shutdown();});+ it.each([false, true])(+ "passes quieter user speech on the first window outside playback (after reply: %s)",+ async (afterReply) => {+ const test = await harness();+ for (let index = 0; index < 5; index++) test.track.frame(1);+ for (let index = 0; index < 10; index++) test.track.frame(0);+ await vi.waitFor(() => expect(test.session().audio).toHaveLength(15));+ if (afterReply) {+ await answeredTurn(test);+ await vi.waitFor(() => expect(test.source().frames).toHaveLength(2));+ test.source().queued = 400;+ for (let index = 0; index < 12; index++) test.track.frame(3);+ await vi.waitFor(() => expect(test.session().audio).toHaveLength(27));+ expect(test.session().audio.at(-1)).toEqual(new Int16Array(320));+ test.session().emit({ type: "response_finished", canceled: false });+ test.source().queued = 0;+ }+ // A stale loud level must not mute a normal turn, even after it gated speech.+ test.track.frame(3);+ await vi.waitFor(() => expect(test.session().audio.at(-1)?.[0]).toBe(3));+ expect(test.source().clears).toBe(0);+ await test.shutdown();+ },+ );+it("sends silence after a moment of local quiet and the held onset when speech resumes", async () => {const test = await harness();const start = test.session().audio.length;diff --git a/apps/voice-runtime/src/live-worker.ts b/apps/voice-runtime/src/live-worker.tsindex 57af0a31..ceec18dd 100644--- a/apps/voice-runtime/src/live-worker.ts+++ b/apps/voice-runtime/src/live-worker.ts@@ -112,7 +112,7 @@ const pauseSpeechSamples = 16_000 * 0.2;* windows and this gate in none.*/const otherSpeakerDb = 10;-/** Speech fainter than this is never the user's, before their level is known. */+/** Playback's minimum speech level before the user's level is known. */const faintestSpeechDb = -50;/** An open gate stays open this much below its threshold, for word tails. */const levelHysteresisDb = 6;@@ -2263,8 +2263,8 @@ export class LiveVoiceWorker {}/**- * Speech near the user's own level. Quieter speech is someone else in the- * room and counts as quiet: it is gated and pauses nothing.+ * During playback, quieter speech counts as quiet and pauses nothing.+ * Otherwise Silero alone gates input, so a stale level cannot mute a turn.*/private isUserSpeech({ speech, levelDb }: SpeechActivity) {const learned = this.userLevelDb;@@ -2273,7 +2273,7 @@ export class LiveVoiceWorker {faintestSpeechDb,learned === undefined ? faintestSpeechDb : learned - otherSpeakerDb,) - (this.userSpeaking ? levelHysteresisDb : 0);- this.userSpeaking = speech && levelDb >= threshold;+ this.userSpeaking = speech && (!this.isPlaying() || levelDb >= threshold);if (this.userSpeaking)this.userLevelDb =learned === undefined