Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Live transcript: whisper's quick readings skip the language guess and come at most once per 1.6 s of a track's audio

christianmat94cf7ab6d7fe
diff --git a/app/src/main/asr/pipeline.ts b/app/src/main/asr/pipeline.ts
index 311350e9..f5543f0e 100644
--- a/app/src/main/asr/pipeline.ts
+++ b/app/src/main/asr/pipeline.ts
@@ -172,6 +172,9 @@ export function createPipeline(p: {
/** a quick reading slower than this means the server is loaded: the next one is skipped */
const SLOW_PARTIAL_MS = 800
let lastPartialMs = 0
+ /** at most one quick reading per this much of a track's audio: the pace the slow-reading skip ended up at anyway */
+ const PARTIAL_GAP_MS = 1600
+ const lastPartialEnd: Record<Track, number> = { me: -Infinity, them: -Infinity }
/**
* A chunk still being spoken: read it quickly, but never in the way of a final on either track (finals always come
* first), and not right after a slow reading. Its words replace those of the same stretch read before.
@@ -179,6 +182,9 @@ export function createPipeline(p: {
const partial = (c: Chunk) => {
const t = c.track
if (!quickReads[t] || !p.emitPartial || closed || running.me || running.them || waiting.me.length || waiting.them.length || lastPartialMs > SLOW_PARTIAL_MS) { if (lastPartialMs > SLOW_PARTIAL_MS) lastPartialMs = 0; return }
+ const end = c.startMs + c.samples.length / 16
+ if (end > lastPartialEnd[t] && end - lastPartialEnd[t] < PARTIAL_GAP_MS) return
+ lastPartialEnd[t] = end
running[t] = true
const t0 = Date.now()
p.transcribe(c, { partial: true })
diff --git a/app/src/main/asr/transcribe.ts b/app/src/main/asr/transcribe.ts
index aa29bf29..f2f156f6 100644
--- a/app/src/main/asr/transcribe.ts
+++ b/app/src/main/asr/transcribe.ts
@@ -86,6 +86,8 @@ export function createTranscriber(o: Opts): Transcribe {
form.set('no_timestamps', 'false')
// a partial is read once, greedily: a few times faster than the server's beam search, good enough for a first look
if (partial) { form.set('beam_size', '1'); form.set('best_of', '1') }
+ // its language is never read: no second pass of the encoder to guess it (about a third of each request)
+ if (partial) form.set('no_language_probabilities', 'true')
if (prompt) form.set('prompt', prompt)
used = await o.url()
return fetchFn(`${used}/inference`, { method: 'POST', body: form, signal: AbortSignal.timeout(o.timeoutMs ?? requestTimeoutMs(c.samples.length)) })
diff --git a/app/test/pipeline.test.ts b/app/test/pipeline.test.ts
index 431adfae..c404e9d8 100644
--- a/app/test/pipeline.test.ts
+++ b/app/test/pipeline.test.ts
@@ -272,6 +272,17 @@ describe('partials, held back when they would get in the way', () => {
expect(parts.length).toBe(before)
expect(asked).toBeGreaterThan(0)
})
+ it('reads a long sentence quickly at most once per 1.6 s of its audio, the pace a loaded server allowed anyway', async () => {
+ const ends: number[] = []
+ const p = createPipeline({
+ meetingId: 'm1', holdMs: 20,
+ transcribe: async (c, o) => { if (o?.partial) ends.push(c.startMs + c.samples.length / 16); return [{ track: c.track, startMs: c.startMs, endMs: c.startMs + 500, text: o?.partial ? 'quick' : 'final' }] },
+ save: () => {}, emit: () => {}, emitPartial: () => {},
+ })
+ const all = tone(4)
+ for (let i = 0; i < all.length; i += 1600) { p.push('them', i / 16, all.subarray(i, i + 1600)); await wait(1) }
+ expect(ends).toEqual([800, 2400, 4000])
+ })
it('one live reading per track: a sentence waiting for its final and the next one show as one, in order, and each final takes only its own words', async () => {
const seen: string[] = []
const p = createPipeline({
diff --git a/app/test/transcribe.test.ts b/app/test/transcribe.test.ts
index 40f58fde..79491f77 100644
--- a/app/test/transcribe.test.ts
+++ b/app/test/transcribe.test.ts
@@ -208,9 +208,12 @@ describe('partials', () => {
expect(quick.map((l) => l.text)).toEqual(['we should move the'])
expect(s.seen[0].fields.beam_size).toBe('1')
expect(s.seen[0].fields.language).toBe('auto')
+ // its language is never read, so whisper skips the second encoder pass that guesses it
+ expect(s.seen[0].fields.no_language_probabilities).toBe('true')
const final = await tr(chunk('them', 1000))
expect(final.map((l) => l.text)).toEqual(['we should move the launch to friday'])
expect(s.seen[1].fields.beam_size).toBeUndefined()
+ expect(s.seen[1].fields.no_language_probabilities).toBeUndefined()
// the partial did not lock the language: the final asked with it open
expect(s.seen[1].fields.language).toBe('auto')
})