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
@@ -286,6 +286,12 @@ export function angleInArc(azimuth: number, arcCenter: number, arcHalfWidth: num
|
||||
export class TempleAudioPipeline {
|
||||
private readonly beamformer: DelaySumBeamformer;
|
||||
private readonly anc = new InterMicNoiseCanceller();
|
||||
// Steering delays reach back before the start of each frame. Carrying the
|
||||
// previous frame's last samples keeps those real; zero-filling them (as a
|
||||
// standalone beam() does) dips the output at every frame boundary.
|
||||
private readonly carry: number;
|
||||
private frontTail: Float32Array;
|
||||
private rearTail: Float32Array;
|
||||
enableANC = true;
|
||||
|
||||
constructor(
|
||||
@@ -294,19 +300,38 @@ export class TempleAudioPipeline {
|
||||
geometry: MicGeometry = G2_DEFAULT_GEOMETRY,
|
||||
) {
|
||||
this.beamformer = new DelaySumBeamformer(sampleRate, geometry);
|
||||
const { front, rear } = geometry.positions[side];
|
||||
const spacing = Math.hypot(front.x - rear.x, front.y - rear.y, front.z - rear.z);
|
||||
this.carry = Math.ceil((spacing / geometry.speedOfSound) * sampleRate) + 1;
|
||||
this.frontTail = new Float32Array(this.carry);
|
||||
this.rearTail = new Float32Array(this.carry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process one frame's deinterleaved front/rear channels toward a
|
||||
* device-frame target, returning the enhanced mono beam for this temple.
|
||||
* Frames must be consecutive: each one continues the previous.
|
||||
*/
|
||||
process(front: Float32Array, rear: Float32Array, target: Bearing): Float32Array {
|
||||
const beam = this.beamformer.beam(this.side, front, rear, target);
|
||||
const n = Math.min(front.length, rear.length);
|
||||
const extendedFront = this.withTail(this.frontTail, front, n);
|
||||
const extendedRear = this.withTail(this.rearTail, rear, n);
|
||||
this.frontTail = extendedFront.slice(n);
|
||||
this.rearTail = extendedRear.slice(n);
|
||||
const beam = this.beamformer
|
||||
.beam(this.side, extendedFront, extendedRear, target)
|
||||
.slice(this.carry);
|
||||
if (!this.enableANC) return beam;
|
||||
// Null-steer reference: the difference channel carries off-axis noise.
|
||||
const n = Math.min(front.length, rear.length);
|
||||
const reference = new Float32Array(n);
|
||||
for (let i = 0; i < n; i++) reference[i] = front[i]! - rear[i]!;
|
||||
return this.anc.process(beam, reference);
|
||||
}
|
||||
|
||||
private withTail(tail: Float32Array, frame: Float32Array, n: number): Float32Array {
|
||||
const out = new Float32Array(tail.length + n);
|
||||
out.set(tail);
|
||||
out.set(frame.subarray(0, n), tail.length);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user