Skip to content

feat: mute system audio during dictation#3

Open
HarshJa1n wants to merge 1 commit intomxvsh:mainfrom
HarshJa1n:feat/mute-system-audio
Open

feat: mute system audio during dictation#3
HarshJa1n wants to merge 1 commit intomxvsh:mainfrom
HarshJa1n:feat/mute-system-audio

Conversation

@HarshJa1n
Copy link
Contributor

@HarshJa1n HarshJa1n commented Mar 7, 2026

Closes #1

Problem

When dictating with Wave, media playing in other apps — music, podcasts, video — bleeds into the microphone. The transcription model hears both the user's voice and background audio, which degrades accuracy and breaks the "fast, quiet dictation" experience Wave is built around.

Implementation

Wave/Utilities/SystemAudioDucker.swift (new file)

A focused CoreAudio helper that reads and writes kAudioDevicePropertyMute on the current default output device:

  • duck() — snapshots the device's current mute state, then mutes it
  • restore() — reapplies the saved state

Using the hardware mute property rather than changing the volume means the user's volume level is never altered. Devices that don't support mute (some Bluetooth sinks) are silently ignored via the CoreAudio return value.

AppState.swift

  • New muteSystemAudio: Bool setting, persisted in UserDefaults
  • SystemAudioDucker.duck() called immediately before AVAudioRecorder starts in startDictation()
  • SystemAudioDucker.restore() called in both the normal stop path (stopDictationAndPaste()) and the recording-failure error path, so audio is always restored even if recording fails to start

HomeView.swift

Toggle("Mute system audio while dictating", …) added to the existing Transcription section alongside the punctuation toggle. Off by default — no behaviour change for existing users.

Validation

image
  • Toggle state persists across app restarts
  • System audio is silenced on hotkey press and restored immediately after recording stops, before transcription begins
  • Disabling the toggle restores original behaviour with no side effects
  • Tested with built-in speakers and Earphones

Adds opt-in setting to silence the default output device while a
dictation session is active, so media playing in other apps cannot
bleed into the microphone and corrupt transcriptions.

Implementation:
- SystemAudioDucker (Utilities/SystemAudioDucker.swift): reads and
  writes kAudioDevicePropertyMute on the current default output device
  via CoreAudio. Saves the device's pre-session mute state and
  restores it on stop, so the user's volume is never touched. Devices
  that don't support the mute property (some Bluetooth sinks) are
  silently ignored.
- AppState: new muteSystemAudio Bool setting persisted in UserDefaults;
  duck() is called right before AVAudioRecorder starts (including
  restore in the error path) and restore() is called as soon as
  recording stops, before the transcription wait.
- HomeView: "Mute system audio while dictating" toggle added to the
  Transcription section alongside the existing punctuation toggle.

Validated: build succeeds, toggle persists across restarts, other audio
is silenced on hotkey press and restored when dictation ends.
@HarshJa1n HarshJa1n marked this pull request as draft March 7, 2026 12:40
@HarshJa1n HarshJa1n marked this pull request as ready for review March 7, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Automatically mute/duck other audio during dictation

1 participant