Skip to content

feat: add audio capture support (issue #4) - #71

Merged
himanshu231204 merged 1 commit into
mainfrom
feature/audio-capture
Aug 31, 2026
Merged

himanshu231204 merged 1 commit into
mainfrom
feature/audio-capture

Conversation

@himanshu231204

@himanshu231204 himanshu231204 commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds loopback (system-audio) capture so agents can record what's playing through the speakers, alongside the existing screenshot capability.
  • New screen_capture_audio MCP tool (9th tool) returns a WAV audio content block.
  • New screensight capture-audio [--duration N] CLI command.
  • Privacy-first: double-gated — master switch and SCREENSIGHT_ENABLE_AUDIO=1 env var must both be on; audio is off by default.
  • Optional extras (pip install 'screensight[audio]'): soundcard + numpy; the core screenshot path has no new dependencies.
  • audio.wav is cleaned up on screensight off, matching frame.jpg hygiene.

Changes

File Change
src/screensight/capture/audio.py New — AudioResult, record_system_audio() via soundcard loopback → 16-bit PCM WAV
src/screensight/config.py AUDIO_PATH, duration/rate constants, audio_enabled()
src/screensight/core.py CaptureAudioOutcome, capture_audio() with double gate + duration clamp
src/screensight/mcp_server.py screen_capture_audio tool (9th); FastMCP Audio block with base64 fallback
src/screensight/__main__.py capture-audio subcommand
src/screensight/state.py turn_off() deletes audio.wav
pyproject.toml Optional [audio] extra
tests/test_audio.py New — 6 tests covering both gates, clamping, failure, cleanup
tests/test_mcp_server.py 8→9 tool count; schema + content-block tests for screen_capture_audio
docs/ + CHANGELOG.md CLI, MCP-tools, configuration reference updated

Platform support

Platform Status
Windows ✅ WASAPI loopback, works out of the box (tested on this machine)
Linux ✅ PulseAudio/PipeWire monitor, works out of the box
macOS / WSL ⚠️ needs BlackHole or SoundFlower virtual output device

Test plan

  • pytest — 58 tests pass (6 new in test_audio.py, 2 updated in test_mcp_server.py)
  • ruff check + ruff format --check — clean
  • E2E on Windows: disabled path → exit 3 with actionable error; enabled path → valid 2-channel 44.1 kHz WAV recorded; screensight off deletes audio.wav

Closes #4

Extends ScreenSight with loopback (system-audio) capture — lets agents
hear what the user is playing, gated by the master switch and a separate
opt-in env var (SCREENSIGHT_ENABLE_AUDIO=1) for privacy.

- New capture/audio.py: record_system_audio() via soundcard WASAPI/Pulse
  loopback → 16-bit PCM WAV with stdlib wave; deps lazily imported so the
  screenshot path is unaffected when [audio] extras aren't installed.
- New MCP tool screen_capture_audio(duration, question) — 9th tool,
  returns a FastMCP Audio content block + text context.
- New CLI command: screensight capture-audio [--duration N].
- config.py: AUDIO_PATH, duration/sample-rate constants, audio_enabled().
- core.py: capture_audio() + CaptureAudioOutcome, double-gated (master
  switch + SCREENSIGHT_ENABLE_AUDIO), duration clamped to 1–30s.
- state.py: turn_off() deletes audio.wav alongside frame.jpg.
- pyproject.toml: optional [audio] extra (soundcard>=0.4.3, numpy>=1.24).
- Tests: 6 new tests in test_audio.py; test_mcp_server updated 8→9 tools
  with schema and content-block tests for screen_capture_audio.
- Docs: cli.md, mcp-tools.md, configuration.md updated with per-OS
  loopback notes (Windows WASAPI ✅, Linux PulseAudio ✅, macOS/WSL ⚠️).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HGJmVMdVAbyTnUV2KYWfF7
Copilot AI lite review requested due to automatic review settings August 31, 2026 17:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@himanshu231204
himanshu231204 merged commit 9249a66 into main Aug 31, 2026
12 checks passed
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.

Add audio capture support

3 participants