Skip to content

[Windows] SpeechSynthesizer outputs to SAPI audio device instead of Windows default device #3

@cdavy2016-hash

Description

@cdavy2016-hash

Description

On Windows, announce.ps1 creates a System.Speech.Synthesis.SpeechSynthesizer instance without calling SetOutputToDefaultAudioDevice(). As a result, the synthesizer outputs to the audio device configured in Windows SAPI settings (Control Panel > Speech), which may differ from the user's default Windows audio device.

Observed behavior

Users who have a wireless headset set as the Windows default playback device receive announcements through the built-in speakers instead. Other Windows applications and NVDA correctly use the default device (the headset), but Claude Code announcements do not.

Root cause

announce.ps1:

$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$synth.Speak($message)

System.Speech.Synthesis.SpeechSynthesizer defaults to the SAPI-configured audio output token, which is stored separately from the Windows audio default and may point to a different device.

Expected behavior

Announcements should follow the Windows default audio output device, consistently with other applications.

Fix

Add a single call before Speak():

$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$synth.SetOutputToDefaultAudioDevice()
$synth.Speak($message)

SetOutputToDefaultAudioDevice() routes audio through the Windows WAVE_MAPPER, which always resolves to the current default playback device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions