Skip to content

fix(voice): add WSL2 PowerShell audio fallback for TTS playback - #68604

Closed
ygd58 wants to merge 1 commit into
NousResearch:mainfrom
ygd58:fix/wsl-tts-powershell-fallback-v2
Closed

fix(voice): add WSL2 PowerShell audio fallback for TTS playback#68604
ygd58 wants to merge 1 commit into
NousResearch:mainfrom
ygd58:fix/wsl-tts-powershell-fallback-v2

Conversation

@ygd58

@ygd58 ygd58 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Context

Ports #63768 forward onto current main per @teknium1's review.

Problem

On WSL2 without a PulseAudio bridge, ffplay and aplay have no audio device and TTS playback silently fails (issue #17608).

Fix

When powershell.exe and ffmpeg are available, convert audio to a uniquely-named WAV in Windows %TEMP% and play via Media.SoundPlayer.

Per review, fixes two gaps:

  1. Exit-status masking: the cleanup subshell was ( ffmpeg && powershell ); rm -f wav -- the shell exits with rm -f's status (always 0), so a real failure could never be detected. Now: ( ffmpeg && powershell ); rc=$?; rm -f wav; exit $rc.
  2. The no-Pulse WSL gate still hard-blocked voice mode entirely even when the PowerShell fallback made TTS output viable. Added _wsl_powershell_tts_available() to downgrade that case from a hard block to a non-blocking notice (recording still needs PulseAudio and that guidance stays visible) -- no cli.py changes needed since it already respects available.

Verification

Fixed the flaky uniqueness test (previously passed trivially on zero captured filenames) and added a real fallback-triggering regression test for the exit-status fix, plus WSL-gate coverage. 10 new/fixed tests; 80/80 in the full tests/tools/test_voice_mode.py file.

Ports NousResearch#63768 forward onto current main per teknium1's review.

On WSL2 without a PulseAudio bridge, ffplay and aplay have no audio
device and TTS playback silently fails (issue NousResearch#17608). When
powershell.exe and ffmpeg are available, convert the audio to a
uniquely-named WAV in the Windows %TEMP% directory and play it via
Media.SoundPlayer.

Per review, this fixes two gaps in the original port:

1. Exit-status masking: the cleanup subshell was
   '( ffmpeg && powershell ); rm -f wav' -- the shell's exit status is
   the LAST command's (rm -f, which is always 0), so a real
   ffmpeg/PowerShell failure could never be detected by the rc-checking
   fallback logic added to the player loop. Now captures the real
   status before cleanup and re-exits with it:
   '( ffmpeg && powershell ); rc=0; rm -f wav; exit '.

2. The no-Pulse WSL gate in detect_audio_environment() still hard-blocked
   voice mode entirely (input AND output) even when the PowerShell
   fallback made TTS output viable. Added _wsl_powershell_tts_available()
   and use it to downgrade the WSL-without-Pulse case from a hard
   'warnings' block to a non-blocking 'notices' entry when the fallback
   is available -- the same PulseAudio-bridge recording guidance is still
   surfaced (mic capture genuinely still needs it), it just no longer
   blocks /voice on for TTS-only usage. cli.py's existing
   env_check['available'] gate needed no changes since it already
   respects this flag.

Also fixed the flaky uniqueness test (the original asserted
len(filenames) >= 2, which passed trivially on zero captured
filenames) and added a real fallback-triggering regression test for
the exit-status fix.

10 new/fixed tests pass in TestWSL2PowerShellFallback and the new
TestWSLAudioEnvironmentGate; 80/80 in the full tests/tools/test_voice_mode.py file.
@alt-glitch alt-glitch added type/bug Something isn't working tool/tts Text-to-speech and transcription platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows P3 Low — cosmetic, nice to have labels Jul 21, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged into main via consolidated salvage PR #73520 (merge e04c2a9ebd). Your WSL2 PowerShell/Media.SoundPlayer TTS playback fallback (gate downgraded to a notice) was cherry-picked with your authorship, merged with #37346's PipeWire detection.

Your contribution is credited to you in git history. Thank you! Closing this PR as merged-via-salvage.

@teknium1 teknium1 closed this Jul 29, 2026
@tiger5325

tiger5325 commented Jul 29, 2026 via email

Copy link
Copy Markdown

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

Labels

P3 Low — cosmetic, nice to have platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows tool/tts Text-to-speech and transcription type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants