Skip to content

Conversation

@selfscrum
Copy link

Summary

  • Add platform detection (macos, wsl, linux)
  • WSL: Play audio via Windows PowerShell MediaPlayer (bypasses WSLg crackling)
  • Linux: Play audio via mpv
  • macOS: Keep existing afplay behavior
  • Use PAI_DIR environment variable for all paths (with ~/.claude fallback)
  • Load .env from both ~/.env and $PAI_DIR/.env
  • Add platform info to /health endpoint

Test plan

  • Tested on WSL2 - voice plays correctly through Windows MediaPlayer
  • Test on macOS (existing behavior should be unchanged)
  • Test on native Linux with mpv installed

🤖 Generated with Claude Code

- Add platform detection (macos, wsl, linux)
- WSL: Play audio via Windows PowerShell MediaPlayer (bypasses WSLg crackling)
- Linux: Play audio via mpv
- macOS: Keep existing afplay behavior
- Use PAI_DIR environment variable for all paths (with ~/.claude fallback)
- Load .env from both ~/.env and $PAI_DIR/.env
- Add platform info to /health endpoint
- Only use macOS-specific fallbacks on macOS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@fayerman-source
Copy link
Contributor

Great work on the Linux/WSL audio support! I tested a similar approach locally and can confirm mpv works well.

Observation: While testing on Ubuntu 24.04/WSL2, I noticed two additional macOS-specific dependencies that still cause errors on Linux:

1. Notification Display (osascript)

ENOENT: no such file or directory, posix_spawn '/usr/bin/osascript'
spawnargs: [ "-e", "display notification \"...\" with title \"PAI Notification\"" ]

Suggested fix: Use notify-send on Linux:

if (isMac) {
  spawn('/usr/bin/osascript', ['-e', `display notification "${message}" with title "${title}"`]);
} else {
  spawn('notify-send', [title, message]);
}

2. Fallback TTS (say)

The fallback speakWithSay() function uses /usr/bin/say which doesn't exist on Linux.

Suggested fix: Use espeak or spd-say on Linux:

if (isMac) {
  spawn('/usr/bin/say', [text]);
} else {
  spawn('espeak', [text]); // or 'spd-say'
}

These are non-blocking errors (the server continues to work), but addressing them would complete the cross-platform support. Happy to submit a follow-up PR if helpful!

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.

2 participants