forked from Blendman974/faceclaw
Fix a bunch of microphone-related bugs
> Most serious fixes > - Recordings kept forever: a recording made with captions off, or with "Save captions" > off, was transcoded to .m4a and kept indefinitely. No conversation linked to it, so > the phone UI never showed it and the retention settings never deleted it. Recording > now only happens alongside a saved caption session, and turning captions off ends > that session's recording properly. > - 4-mic mode went silent after a reconnect: a disconnect clears the phone's audio > forwarding, and nothing turned it back on, so the app kept showing "Listening (4-mic > array)" while hearing nothing. A check every 3 s now restores forwarding and re-sends > the config when it has been lost. The normal single-stream mode already recovered on > its own. > - Turning off "4-mic capture" mid-session went silent: it stopped the glasses' stream > but never switched to the normal stream. Setup changes now take effect live, > including switching between the two modes. > - Setup changes were undone: after the assistant closed, the app re-sent the config it > loaded at launch to the glasses, reverting any changes you'd made since. > - Startup failures: if the caption engine failed to start, the session got stuck > half-running. If the glasses weren't connected, listeners piled up and an empty > conversation could be left open. Startup now brings up the microphone first and > cleans up properly on failure. > > Other fixes > - Audio quality: the 4-mic beamformer put a small dropout at the start of every 25 ms > frame (an audible 40 Hz artifact in the audio feeding captions). Fixed, with a test > that fails on the old code. > - Stale direction data: an arm that stopped sending kept steering the direction > estimate and could hold the caption feed on a silent arm. > - Compass: closing Microphones switched off the Compass app's compass, because both > used the same owner name. > - Speaker database failures: > - A failed speaker reload wiped the in-memory list, so the next voice became a > duplicate "Speaker N". > - A failed speaker insert crashed caption handling; in re-diarize it reassigned > transcript lines to a nonexistent speaker. > - Translation: > - A crash path inside the model-download callback is now caught. > - Phones set to Hebrew, Indonesian or Yiddish never got translations, because of > old-style language codes. > - Ask questions: once the speaker list grew past the size limit (every unknown voice > adds a "Speaker N"), it pushed all transcript lines out of the context sent to the > model. When trimming is needed, the oldest lines now go first. > - Smaller fixes: > - The captions view stopped jumping back to live speech after 60 lines. > - "This is Dana calling…" was treated as introducing someone else. > - A model download that failed to start was stuck at "downloading" until restart. > - The developer mic monitor grew without limit while hidden.
This commit is contained in:
1 parent
22c31f4240
commit
b50898ea02
14 files changed
+409
-143
No files matched your search
@@ -16,6 +16,10 @@ declare const com: any;
|
||||
|
||||
// Qwen runs with a 4096-token context; leave room for the answer.
|
||||
const MAX_CONTEXT_CHARS = 7000;
|
||||
// The speaker roster grows with every voice ever heard; cap it and the
|
||||
// conversation list so they can't crowd the transcript excerpts out.
|
||||
const MAX_HEADER_CHARS = MAX_CONTEXT_CHARS / 2;
|
||||
const EXCERPTS_HEADING = "# Transcript excerpts\n";
|
||||
const MAX_KEYWORDS = 6;
|
||||
const SEGMENTS_PER_KEYWORD = 30;
|
||||
const RECENT_SEGMENT_LIMIT = 120;
|
||||
@@ -156,31 +160,57 @@ function buildContext(question: string): { context: string; note: string } {
|
||||
}
|
||||
}
|
||||
|
||||
const segments = [...segmentMap.values()].sort((a, b) => a.startedAt - b.startedAt);
|
||||
let header =
|
||||
`# Known speakers\n${speakerLines.join("\n") || "(none yet)"}\n\n` +
|
||||
`# Conversations${filters.sinceMs !== null || filters.emotion !== null ? " (filtered by the question)" : ""}\n` +
|
||||
`${sessionLines.join("\n") || "(none in range)"}\n\n`;
|
||||
let truncated = false;
|
||||
if (header.length > MAX_HEADER_CHARS) {
|
||||
header = `${header.slice(0, MAX_HEADER_CHARS)}\n(...)\n\n`;
|
||||
truncated = true;
|
||||
}
|
||||
|
||||
const sessionHeading = (sessionId: number) =>
|
||||
`\n## ${sessionTitles.get(sessionId) ?? `Conversation #${sessionId}`}`;
|
||||
const segmentText = (segment: SegmentRow) => {
|
||||
const speaker =
|
||||
segment.speakerId !== null ? (speakerNames.get(segment.speakerId) ?? "Speaker") : "Speaker";
|
||||
const emotion = segment.emotion && segment.emotion !== "neutral" ? ` [${segment.emotion}]` : "";
|
||||
const line = `[${formatWhen(segment.startedAt)}] ${speaker}${emotion}: ${segment.text}`;
|
||||
return segment.translation ? `${line}\n (translated: ${segment.translation})` : line;
|
||||
};
|
||||
|
||||
// Fill the remaining budget newest-first, so an overflowing history drops
|
||||
// its oldest excerpts rather than its most recent ones.
|
||||
const sorted = [...segmentMap.values()].sort((a, b) => a.startedAt - b.startedAt);
|
||||
let budget = MAX_CONTEXT_CHARS - header.length - EXCERPTS_HEADING.length;
|
||||
const segments: SegmentRow[] = [];
|
||||
let runSession = -1;
|
||||
for (let index = sorted.length - 1; index >= 0; index--) {
|
||||
const segment = sorted[index]!;
|
||||
let cost = segmentText(segment).length + 1;
|
||||
if (segment.sessionId !== runSession) cost += sessionHeading(segment.sessionId).length + 1;
|
||||
if (cost > budget) {
|
||||
truncated = true;
|
||||
break;
|
||||
}
|
||||
budget -= cost;
|
||||
runSession = segment.sessionId;
|
||||
segments.push(segment);
|
||||
}
|
||||
segments.reverse();
|
||||
|
||||
const excerptLines: string[] = [];
|
||||
let currentSession = -1;
|
||||
for (const segment of segments) {
|
||||
if (segment.sessionId !== currentSession) {
|
||||
currentSession = segment.sessionId;
|
||||
excerptLines.push(`\n## ${sessionTitles.get(currentSession) ?? `Conversation #${currentSession}`}`);
|
||||
excerptLines.push(sessionHeading(currentSession));
|
||||
}
|
||||
const speaker =
|
||||
segment.speakerId !== null ? (speakerNames.get(segment.speakerId) ?? "Speaker") : "Speaker";
|
||||
const emotion = segment.emotion && segment.emotion !== "neutral" ? ` [${segment.emotion}]` : "";
|
||||
excerptLines.push(`[${formatWhen(segment.startedAt)}] ${speaker}${emotion}: ${segment.text}`);
|
||||
if (segment.translation) excerptLines.push(` (translated: ${segment.translation})`);
|
||||
excerptLines.push(segmentText(segment));
|
||||
}
|
||||
|
||||
let context =
|
||||
`# Known speakers\n${speakerLines.join("\n") || "(none yet)"}\n\n` +
|
||||
`# Conversations${filters.sinceMs !== null || filters.emotion !== null ? " (filtered by the question)" : ""}\n` +
|
||||
`${sessionLines.join("\n") || "(none in range)"}\n\n` +
|
||||
`# Transcript excerpts\n${excerptLines.join("\n") || "(no matching lines)"}`;
|
||||
let truncated = false;
|
||||
if (context.length > MAX_CONTEXT_CHARS) {
|
||||
context = context.slice(0, MAX_CONTEXT_CHARS);
|
||||
truncated = true;
|
||||
}
|
||||
const context = `${header}${EXCERPTS_HEADING}${excerptLines.join("\n") || "(no matching lines)"}`;
|
||||
const note =
|
||||
`${sessions.length} conversation${sessions.length === 1 ? "" : "s"}, ` +
|
||||
`${segments.length} transcript line${segments.length === 1 ? "" : "s"} consulted` +
|
||||
|
||||
Reference in new issue
Block a user