Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CLAUDE.md

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion Sources/PladderCore/DictationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public final class DictationCoordinator {
public var minimumPolishWords = 4
// A key-up can be lost for real, e.g. while Secure Event Input hides keys from the tap.
public var maximumDuration: Duration = .seconds(600)
// A latched recording has no key-up to lose; its cap only ends a forgotten latch.
public var latchedMaximumDuration: Duration = .seconds(3600)
// Handy and VoiceInk use 300 to 500 ms.
public var holdThreshold: Duration = .milliseconds(400)
public var bounceWindow: Duration = .milliseconds(50)
Expand Down Expand Up @@ -400,9 +402,14 @@ public final class DictationCoordinator {
self.inputLevel = level
}
}
maxDurationTask = Task { [weak self, clock, maximumDuration] in
maxDurationTask = Task { [weak self, clock, maximumDuration, latchedMaximumDuration] in
try? await clock.sleep(for: maximumDuration)
guard let self, !Task.isCancelled, self.state.isRecording else { return }
// Asked at the held cap, not at the press: a hybrid key latches at its release.
if self.isLatched {
try? await clock.sleep(for: latchedMaximumDuration - maximumDuration)
guard !Task.isCancelled, self.state.isRecording else { return }
}
// A lost key-up, not a release: never send a message unattended.
self.hotkeyReleased(submit: false)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/PladderCore/Learning/CorrectionDiff.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum CorrectionDiff {
// So a one- or two-word paste can still be corrected.
static let rewriteAllowance = 2
// Past this the reading is skipped rather than a quadratic table built; a
// dictation near the 10 min cap can pass it, and then nothing is learned.
// dictation of ten minutes or more can pass it, and then nothing is learned.
static let maximumCells = 4_000_000

public static func candidates(in observation: PasteObservation) -> [CorrectionPair] {
Expand Down
9 changes: 7 additions & 2 deletions Sources/PladderEngines/FluidAudioIncrementalEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public actor FluidAudioIncrementalEngine: StreamingTranscriptionEngine {
private var manager: AsrManager?
private var slot = UtteranceSlot<IncrementalChunkProcessor>()
private var fedSampleCount = 0
// Kept only for `livePass`; the session holds its own copy. 38 MB at the 10 min cap,
// dropped when the utterance ends.
// Kept only for `livePass`, trimmed to its last window or two; the session holds the
// whole recording.
private var liveAudio: [Float] = []
private var loadTask: Task<Void, Error>?

Expand Down Expand Up @@ -171,6 +171,11 @@ public actor FluidAudioIncrementalEngine: StreamingTranscriptionEngine {
guard !samples.isEmpty, let session = slot.session(for: utterance) else { return }
fedSampleCount += samples.count
liveAudio.append(contentsOf: samples)
// Only the last window is read; whole hops off the front leave its cut where it was.
if liveAudio.count > 2 * Self.maxWindowSamples {
let overflow = liveAudio.count - Self.maxWindowSamples
liveAudio.removeFirst((overflow / Self.windowHopSamples) * Self.windowHopSamples)
}
// A window failing mid-recording must not take the dictation down: `finish()` still
// runs the last window and merges what succeeded.
try? await session.append(samples)
Expand Down
8 changes: 7 additions & 1 deletion Tests/PladderCoreTests/DictationCoordinatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ final class EventLog: @unchecked Sendable {
await c.cancelRecording()
}

@Test func theCapFiresInToggleMode() async {
@Test func aLatchedRecordingOutlastsTheHeldCap() async {
let hotkey = FakeHotkey()
let clock = ManualClock()
let (c, output, _) = makeCoordinator(settings: hybridSettings(), hotkeyMonitor: hotkey, clock: clock)
Expand All @@ -1273,7 +1273,13 @@ final class EventLog: @unchecked Sendable {
hotkey.release()
#expect(await waitUntil { c.isLatched })
#expect(await clock.waitForSleepers(2))
let sleepers = clock.sleeperCount
clock.advance(by: c.maximumDuration)
#expect(await waitUntil { clock.sleeperCount == sleepers })
#expect(c.state.isRecording)
clock.advance(by: c.latchedMaximumDuration - c.maximumDuration - .seconds(1))
#expect(c.state.isRecording)
clock.advance(by: .seconds(1))
await c.cycleFinished()
#expect(output.inserted.count == 1)
#expect(output.submitted == [false])
Expand Down
6 changes: 4 additions & 2 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ its timers with `ManualClock`.
drops that utterance itself and starts no loop. At release or cancel the
session hands the coordinator what it ended with: the utterance or the
whole buffer to transcribe, and the feed loop to wait for;
6. starts the level meter and the 10 minute cap.
6. starts the level meter and the cap: 10 minutes, or 60 if the recording
is latched by then.

**Release** (`hotkeyReleased`). `endRecording()` stops everything the press
started: the gesture tracker, the cancel key, the meter, the cap, the feed,
Expand Down Expand Up @@ -690,7 +691,8 @@ that default.
| 0.3 s | Shortest recording that is transcribed | `DictationCoordinator.minimumDuration` | `PladderCore/DictationCoordinator.swift` |
| 4 words | Shortest dictation that is polished | `DictationCoordinator.minimumPolishWords` | `PladderCore/DictationCoordinator.swift` |
| 10 words | Longest sentence pasted without its capital and period | `ShortSentence.maximumWords` | `PladderCore/Support/ShortSentence.swift` |
| 10 min | Recording cap | `DictationCoordinator.maximumDuration` | `PladderCore/DictationCoordinator.swift` |
| 10 min | Recording cap, held | `DictationCoordinator.maximumDuration` | `PladderCore/DictationCoordinator.swift` |
| 60 min | Recording cap, latched | `DictationCoordinator.latchedMaximumDuration` | `PladderCore/DictationCoordinator.swift` |
| 100 ms | Feed loop cadence, and the chunk the paced bench feeds | `DictationCoordinator.defaultFeedInterval` | `PladderCore/DictationCoordinator.swift` |
| 500 ms | Live pass cadence (Live Transcript) | `DictationCoordinator.livePassInterval` | `PladderCore/DictationCoordinator.swift` |
| 2 s | Warm loop cadence | `DictationCoordinator.warmupInterval` | `PladderCore/DictationCoordinator.swift` |
Expand Down
22 changes: 21 additions & 1 deletion docs/BENCHMARKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ them.
| 60s | 60 s | Chunked path. |
| 2m | 2 min | A long dictation. |
| 5m | 5 min | A very long dictation. |
| 10m | 10 min | The app's recording cap. Heats the chip, so it runs last. |
| 10m | 10 min | The app's cap for a held recording. Heats the chip, so it runs last. |

30 s through 10 min show whether engine time grows linearly with chunk count
and whether accuracy degrades at chunk seams, which FluidAudio's own notes
Expand Down Expand Up @@ -398,6 +398,26 @@ whole-buffer text from 30 s up, and its word error was 0.9 to 1.2 % from
60 s up where the batch path's was 0.0 to 0.2 %. That is why the fork's
`IncrementalChunkProcessor` stays.

## Past ten minutes

A latched recording runs up to 60 minutes, longer than any standard
fixture. Checked once on 2026-11-17 on the M1 (macOS 27.2), Parakeet Ultra,
with a 60m fixture made by joining the 10m one six times (3,789 s) and the
paced bench with its sleep taken out, so the audio was fed as fast as the
windows ran. Every window is still run before `endUtterance`, which is what
the timing needs; only the wall clock is shorter.

| Fixture | Audio | `endUtterance` (median of 2) | WER | Identical whole-buffer |
|---|---:|---:|---:|---|
| 10m | 631 s | 0.179 s | 0.5 % | yes |
| 60m | 3,789 s | 0.206 s | 0.6 % | yes |

Six times the audio leaves 27 ms more at release, the last window
and the merge over six times as many windows. The whole-buffer pass over the 60m fixture took 19.3 s, the wait
the incremental path saves. The CLI's peak footprint was 813 MB, with the
fixture itself and that whole-buffer pass in it. In the app the recording
holds about 230 MB in FluidAudio's session until the release.

## Reading the app's release-to-paste log

Every dictation logs one line with the total release-to-paste time, its
Expand Down
2 changes: 1 addition & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ The 25 European languages Parakeet TDT v3 supports, including English, German, F

## Long dictations

Recordings stop at 10 minutes, so a lost key-up never leaves the microphone on; what was said up to then is pasted. Audio longer than 15 seconds is transcribed in overlapping windows while you are still speaking, so the wait after letting go stays the same.
A held recording stops at 10 minutes, so a lost key-up never leaves the microphone on; what was said up to then is pasted. A recording started with the hands-free key runs up to 60 minutes. Audio longer than 15 seconds is transcribed in overlapping windows while you are still speaking, so the wait after letting go stays the same.

## From the command line

Expand Down
2 changes: 1 addition & 1 deletion scripts/make-fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# RATE=<wpm> speaking rate, default 175
#
# Lengths: 10 s (one encoder window), 30 s, 60 s, 2 min, 5 min and 10 min (the
# app's recording cap). The script is read in
# app's cap for a held recording). The script is read in
# sentence order, wrapping around for the long fixtures, until the estimated
# duration reaches the target, so each file is a whole number of sentences.
set -euo pipefail
Expand Down
Loading