8000 Recording drops first word after start chime · Issue #179 · amicalhq/amical · GitHub
[go: up one dir, main page]

Skip to content

Recording drops first word after start chime #179

Open

Description

@pmjbaumann

Describe the bug
The first ~1s of speech is dropped from recordings when dictation starts right after the "start" chime. Confirmed by listening back to the raw audio — the words genuinely aren't captured, so it's not a transcription/formatting issue downstream.

App Version
v1.11.3 (macOS build; confirmed the same logic is unfixed on main at v1.12.0-beta.1)

Model Information
Amical Cloud, but I believe the issue persists across all models.

System Information
Operating System: macOS 26.6 (Tahoe)
RAM: 64GB
GPU: Apple Silicon M1 Max
CPU: Apple Silicon M1 Max

To Reproduce
Trigger dictation via global hotkey with sounds enabled (muteDictationSounds off, the default)
Start speaking the instant the start chime finishes
Stop dictation and listen back to / inspect the recorded audio
The first word (or part of it) is missing from the captured audio, not just the transcript

Expected behavior
All speech spoken after the chime audibly ends should be captured, not just speech spoken after the chime's IPC round-trip resolves.

Root cause (according to Claude) UPDATE: SEE FURTHER COMMENT FROM ME BELOW
recording-manager.ts drops any audio chunk that arrives while this.initPromise is still unresolved, treating that as "definitely chime noise":

// apps/desktop/src/main/managers/recording-manager.ts:975-997
const capturedDuringStartSound = this.initPromise !== null;
...
if (capturedDuringStartSound && !this.soundsMuted && !isFinalChunk) {
  logger.audio.debug("Dropping start-sound-window chunk");
  return;
}

But initPromise doesn't resolve when the chime audio finishes — it resolves after an additional round-trip through the Swift helper (RpcHandler.swift:158-179): the AVAudioPlayer delegate callback → JSON-RPC encode → stdio → back into the Electron main process. So real speech spoken in that gap (chime audibly done, RPC not yet back) still arrives while initPromise is non-null and gets discarded as if it were chime noise.

A more accurate fix would gate the drop on actual elapsed audio time (the chime's known duration) rather than on promise resolution timing.

Activity

  1. haritabh-z01 commented on Aug 10, 2026

    @haritabh-z01
    Contributor

    @pmjbaumann While the round trip claim is true, but that shouldn't take anywhere close to 1s, based on all the testing I have done its generally in the order of 10s of ms or even lower.
    Can you please share what macbook version are you using? @pmjbaumann

  2. pmjbaumann commented on Aug 10, 2026

    @pmjbaumann
    Author

    Macbook Pro M1 Max 64GB RAM.

  3. haritabh-z01 commented on Aug 10, 2026

    @haritabh-z01
    Contributor

    and you are testing with internal built in mic / wired mic right? since bt mics (including airpods) sometimes have startup delay.

  4. pmjbaumann commented on Aug 10, 2026

    @pmjbaumann
    Author

    Yep, inbuilt mic on the macbook pro.

  5. pmjbaumann commented on Aug 10, 2026

    @pmjbaumann
    Author

    I'm just running some tests. Discovered that changing my audio output from an external speaker to the internal speakers fixed the problem. So all things being equal, having the audio output set to something other than the internal speakers seems to cause the dropped recorded audio bug.

  6. pmjbaumann commented on Aug 10, 2026

    @pmjbaumann
    Author

    Here is the Claude diagnosis after digging into this locally. Some of the tests we did were non-scientific (me counting out loud into the mic), so probably best to treat the device comparison as indicative. The timing numbers should be more solid as they come straight from Amical's own log output rather than anything measured externally.


    The real cause: getUserMedia is on the hotkey critical path

    Microphone acquisition starts when the hotkey is pressed, so capture does not exist yet when recording begins. Everything spoken during acquisition is never captured.

    From 118 sessions:

    keypress -> first audio frame:  min 342  median 953  p90 1214  max 1849 ms
    getUserMedia (default):         min 245  median 821  p90 1058  max 1623 ms
    AudioCapture Total startup:     min 310  median 900  p90 1136  max 1672 ms
    

    A single session in full:

    01.306  main sends startRecording
    01.309  AudioCapture: Starting audio capture
    01.654  getUserMedia (default) took 345.00ms
    01.708  Total startup took 400.90ms
    01.794  First audio frame received after 86.20ms
    01.875  Recording started
    01.890  First audio chunk received
    

    Everything between 01.306 and 01.794 is gone. The comment at recording-manager.ts:989 stating "Capture is already live (no added start latency)" is the incorrect premise. Capture is not live at that point, it is still being acquired.

    It gets worse depending on your audio output device

    This is the rudimentary bit. Eight dictations, counting "one two three four five six seven eight" at a steady pace, starting the instant I pressed the hotkey. The only thing changed between blocks was the system output device. The microphone was Default - MacBook Pro Microphone (Built-in) throughout.

    # Output device getUserMedia keypress→first audio Transcript
    1 Clarett 8Pre 875ms 1030ms 2,3,4,5,6,7,8
    2 Clarett 8Pre 797ms 961ms 2,3,4,5,6,7,8
    3 Clarett 8Pre 815ms 976ms 3,4,5,6,7,8
    4 C34H89x 346ms 443ms 1,2,3,4,5,6,7,8
    5 C34H89x 327ms 413ms 2,3,4,5,6,7,8
    6 C34H89x 328ms 426ms 1,2,3,4,5,6,7,8
    7 C34H89x 331ms 422ms 1,2,3,4,5,6,7,8
    8 C34H89x 346ms 434ms 2,3,4,5,6,7,8

    Acquiring the built-in microphone takes about 2.5x longer when a Thunderbolt audio interface is merely selected for output. Lost a number in 3 of 3 on the Clarett, 2 of 5 on the DisplayPort monitor. My counting pace was not perfectly metronomic and the sample is small, so the exact word counts are illustrative, but the underlying millisecond figures are logged by the app and line up with them.

    The fix may already be half-built

    Amical already keeps part of the audio path warm between dictations, in audioCaptureRecycle.ts. It just warms the cheap half:

    Component Typical cost Current behaviour
    getUserMedia (mic stream) ~821ms Destroyed after every dictation via track.stop()
    AudioContext (audio graph) ~50 to 77ms Kept warm for 5 minutes (AUDIO_CONTEXT_IDLE_TIMEOUT_MS)

    The AudioContext is deliberately held for five minutes so restarts are fast, while the component costing roughly ten times more is torn down every single time. Extending the same idle-recycle treatment to the MediaStream would mean a burst of dictations after the first is instant, and the stream is still released once the user has clearly stopped.

    The obvious trade-off is that holding the stream keeps the macOS microphone indicator lit, which may be exactly why it was not done. A shorter idle window than the existing five minutes might be the right compromise.

    Caveats

    • One machine, macOS 26.6, v1.11.3, Apple Silicon, Amical Cloud.
    • Device attribution for the 118-session background figures is inferred from timestamps, not logged. Only the eight-dictation test above was a controlled comparison.
    • logger.audio.debug is off in release builds, so the "drop window never fires" conclusion comes from comparing chunk arrival times against initPromise resolution, not from observing the discard directly.
    • Transcripts came from the local transcriptions table, timings from the widget's own AudioCapture log lines.
  7. haritabh-z01 commented on Aug 10, 2026

    @haritabh-z01
    Contributor

    @pmjbaumann are you sure that you did this analysis with the latest code?

  8. pmjbaumann commented on Aug 10, 2026

    @pmjbaumann
    Author

    My app is 1.11.3 (which will be what the non-scientific live tests were running on) — that's the latest it's showing as available when I do a 'check for update' pass.

    Claude was analysing the latest code available on github, I believe, but I can check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0