← Portfolio/free-code

free-code

Vision Mode — See the screen. Hear your voice. Respond naturally.

What is Vision Mode?

Multimodal AI agent with eyes, ears, and voice — hands-free assistance powered by your screen and speech.

Vision Mode brings multimodal capabilities to free-code: screen capture, speech-to-text (STT), and text-to-speech (TTS). The agent can see what's on your screen, listen to your voice, and speak answers back.

Built on a snapshot-at-question-time model — no continuous video upload, no streaming. The agent receives one image at the moment you ask, plus the conversation history. This keeps cost low, latency reasonable, and privacy high.

Example
Open a browser with an error page, say "free-code, what is this error?", and the agent captures the screen, reads the stack trace, and answers out loud — zero typing required.

How it works

Three interaction modes, one seamless pipeline.

Three commands

ModeCommandUse case
On-demand vision /see <question> Capture screen once, ask about it. Typed question, instant screenshot.
Push-to-talk /voice [context] Record audio, transcribe, send. No screen capture unless explicitly requested.
Live hands-free /vision live on Continuous listening with wake word. Auto-captures when vision keywords detected. Speaks responses.

The pipeline

StepWhat happensConfigurable backends
1. Screen capture Grabs a single frame of the current screen Portal (Wayland), scrot, gnome-screenshot, spectacle, import, screencapture (macOS), PowerShell
2. Image resize Downscales to max 1568px (configurable) with Photon WASM JPEG quality 85 (default), ~1.1–1.6k tokens per image
3. Audio record Records microphone input until stopped (PTT or VAD) pw-record, arecord, sox, ffmpeg
4. Speech-to-text Transcribes audio to text OpenAI Whisper, Groq Whisper, local whisper.cpp
5. Agent turn Sends text + optional image to the model Any vision-capable model: GPT-4o, Claude 3.5, Gemini 2.0 Flash, etc.
6. Text-to-speech Speaks the assistant's reply (live mode only) OpenAI TTS, espeak, macOS say
Why snapshot instead of video?
A 10-second video at 1 frame per second = 10 images = 10–15k tokens. One snapshot at question time = 1.5k tokens. The agent doesn't need to see continuous motion — it needs context for the question you asked.

Flow diagrams

Visualizing the three interaction modes.

1 · On-demand vision (/see)

/see <question> Typed by user Capture screen Portal / scrot / etc. Resize image Max 1568px, JPEG Model Text + Image
Single-shot: question → capture → resize → model answer

2 · Push-to-talk (/voice)

Hotkey press Start/stop record Record audio pw-record / arecord Transcribe Whisper / Groq Send / Review voiceMode config
Push-to-talk: record → transcribe → send (or place in editor for review)

3 · Live hands-free mode (/vision live on)

Listen Wake word + VAD Transcribe STT backend Vision check "mira", "pantalla" Capture? If keywords match Model Text (+ Image?) Speak TTS backend Loop (agent_end)
Live loop: listen → transcribe → check keywords → capture (if needed) → model → speak → repeat

Commands

All vision-mode slash commands and shortcuts.

CommandDescription
/see <question>Capture screen and ask about it (one-shot vision)
/voice [context]Push-to-talk: record, transcribe, send (or review)
/vision live onStart continuous hands-free mode with wake word
/vision live offStop live mode
/vision statusShow current backends, language, mode settings
/vision backendsList available capture/STT/TTS backends and whether they're installed
/vision configView all configuration values
/vision config <key>View a single config value
/vision config <key> <value>Set a config value

Keyboard shortcut

Push-to-talk is registered as a global shortcut (default: configurable via VISION_SHORTCUT env var or vision.json). Press once to start recording, press again to stop and transcribe.

In live mode
The PTT shortcut interrupts the current capture/recording — useful if the agent is listening too long or you want to barge in mid-turn.

Configuration

All settings, environment variables, and config file location.

Config file

Vision Mode settings are stored in ~/.free-code/vision.json. Edit directly or use /vision config <key> <value>.

Environment variables (override config file)

VariableDescription
VISION_CAPTURE_BACKENDCapture method: auto, portal, grim, scrot, import, screencapture, powershell
VISION_STT_BACKENDSTT backend: auto, openai, groq, whisper-cpp
VISION_TTS_BACKENDTTS backend: auto, openai, espeak, say
VISION_LANGUAGELanguage code: es, en, auto
VISION_VOICE_MODETranscript destination: send (automatic) or review (placed in editor)
VISION_SHORTCUTPTT hotkey (e.g., ctrl+shift+space)
OPENAI_API_KEYRequired for OpenAI STT/TTS
GROQ_API_KEYRequired for Groq STT

CLI flags (override env vars)

FlagDescription
--vision-capture-backend <id>Force a specific capture backend
--vision-stt-backend <id>Force a specific STT backend
--vision-tts-backend <id>Force a specific TTS backend
--vision-language <code>Override language
--vision-voice-mode <mode>Override voice mode

All config keys

KeyDefaultDescription
captureBackend"auto"Screen capture method
captureInteractivetrueAllow monitor/window selection dialogs
captureMaxWidth1568Max image dimension before resize (0 = no resize)
captureJpegQuality85JPEG compression quality (0–100)
sttBackend"auto"Speech-to-text backend
sttModel"whisper-1"Model name for API STT (OpenAI/Groq)
ttsBackend"auto"Text-to-speech backend
ttsModel"tts-1"TTS model (OpenAI)
ttsVoice"alloy"TTS voice (OpenAI: alloy, echo, fable, onyx, nova, shimmer)
language"auto"STT language code
voiceMode"review"Where transcript goes: send or review
shortcutnullPTT hotkey (e.g., "ctrl+shift+space")
voiceCommandDuration6000Max recording duration for /voice command (ms)
liveTurnMaxMs8000Max recording duration per live-mode turn (ms)
liveAlwaysCapturefalseCapture screen on every utterance (ignore keyword detection)
liveWakeWord"freecode"Wake word to activate processing (comma-separated for multiple)
liveSpeaktrueSpeak assistant responses in live mode
liveIndicatortrueShow status indicator when live mode is active
Example: Spanish setup with Groq STT
export GROQ_API_KEY="gsk_..."
/vision config language es
/vision config sttBackend groq
/vision config liveWakeWord "oye,free-code"
/vision live on

Privacy & cost

What gets captured, when, and how much it costs.

Privacy model

  • Explicit opt-in: Vision Mode commands must be invoked manually. Live mode requires /vision live on.
  • No continuous upload: Screen is captured only at the moment you ask a question (or when vision keywords are detected in live mode).
  • Visible indicator: Live mode shows a status indicator (👁 live · listening…) so you know it's active.
  • Portal consent (Wayland): The XDG Desktop Portal shows a permission dialog before granting screen access — OS-level consent.
  • Local backends: Use whisper.cpp (local STT) + espeak/say (local TTS) for fully private, zero-API mode.

Token cost

One downscaled image (1568px max, JPEG quality 85) ≈ 1.1–1.6k input tokens.

ScenarioImages sentEst. image tokens
10 /see questions10~11–16k
30-question live session (vision keywords in half)15~16–24k
100-question live session (liveAlwaysCapture=true)100~110–160k

Compare to text-only: a 500-line file ≈ 3–5k tokens. Vision adds cost, but the snapshot model keeps it reasonable — you're not streaming 30fps video.

Latency budget

Target: under 5 seconds from "stop talking" to "agent starts speaking" (live mode).

  • VAD silence detection: ~300ms
  • Local whisper.cpp (base model): ~500–1000ms
  • Screen capture: ~100ms
  • Model first token: ~1–2s (depends on provider/load)
  • TTS first audio chunk: ~500ms (streaming)

Total: ~2.4–4s under ideal conditions. Groq STT can shave off another ~500ms (faster than local Whisper).

Installation & dependencies

What to install for each backend.

Vision Mode is included in the default free-code installation. You need to install system dependencies for the backends you want to use.

Screen capture

Pick one (or install multiple; auto will choose the best available):

  • Linux/Wayland: xdg-desktop-portal-gnome (recommended), or grim / gnome-screenshot / spectacle / scrot / ImageMagick import
  • Linux/X11: scrot or import
  • macOS: screencapture (built-in, no install needed)
# Ubuntu/Debian (Wayland)
sudo apt install xdg-desktop-portal-gnome

# Fedora (Wayland)
sudo dnf install xdg-desktop-portal-gnome

# Arch (Wayland)
sudo pacman -S xdg-desktop-portal-gnome

# Fallback: scrot (X11)
sudo apt install scrot

Audio recording

One of:

  • pw-record (PipeWire, modern Linux — usually pre-installed on recent distros)
  • arecord (ALSA)
  • sox (cross-platform)
  • ffmpeg
# Check if pw-record exists (PipeWire)
which pw-record

# Install ALSA utils (includes arecord)
sudo apt install alsa-utils

# Or install SoX
sudo apt install sox

Speech-to-text

API-based (easiest):

# OpenAI Whisper
export OPENAI_API_KEY="sk-..."

# Groq (faster, free tier available)
export GROQ_API_KEY="gsk_..."

Local (no API cost, fully private):

Install whisper.cpp:

git clone https://github.com/ggerganov/whisper.cpp.git
cd whisper.cpp
make
# Download a model (base is fast, small is smaller, large is most accurate)
bash ./models/download-ggml-model.sh base
# Ensure 'whisper' binary is in PATH or specify path via VISION_WHISPER_CPP_PATH

Text-to-speech

API-based:

export OPENAI_API_KEY="sk-..."   # for tts-1 model

Local:

# Linux: espeak
sudo apt install espeak

# macOS: say (built-in, no install needed)

Verify backends

After installing dependencies, check what's available:

/vision backends

Output shows ✓ for available backends, ✗ for missing ones.

Examples

Common workflows and use cases.

1. Debug a visual error

Open a browser with a stack trace or error page:

/see what is this error and how do I fix it?

Agent captures the screen, reads the stack trace, and explains the issue.

2. Code review via screen share

Open a diff or PR in GitHub/GitLab:

/see review this diff for potential issues

3. Hands-free pair programming

Start live mode while coding:

/vision config liveWakeWord "free-code"
/vision config language en
/vision live on

# Now say: "free-code, what does this function do?"
# Agent captures screen, sees the code, answers out loud.

4. Transcribe meeting notes

Use push-to-talk to record summaries without typing:

/voice
# Press PTT hotkey, speak notes, release
# Transcript appears in editor for review before sending

5. Fully private local mode

No API calls, all processing on your machine:

/vision config sttBackend whisper-cpp
/vision config ttsBackend espeak   # or 'say' on macOS
/vision config captureBackend portal  # or 'scrot' on X11

# Now all /see, /voice, and live mode use local backends only

Troubleshooting

Common issues and fixes.

"No capture backend available"

Install at least one screen capture tool. Check what's available:

/vision backends

On Wayland, install xdg-desktop-portal-gnome. On X11, install scrot.

"No audio recorder found"

Install one of: pw-record, arecord, sox, or ffmpeg.

which pw-record arecord sox ffmpeg

"Could not resize the screenshot (Photon unavailable)"

The Photon WASM asset is missing. Reinstall free-code or check packages/coding-agent/assets/photon_rs_bg.wasm.

Live mode doesn't activate on speech

Check wake word configuration:

/vision config liveWakeWord

Make sure you say the exact wake word at the start of your utterance. Try:

/vision config liveWakeWord "hey,oye,freecode"

This allows any of those three to activate.

Images are too large / too expensive

Reduce max dimension or JPEG quality:

/vision config captureMaxWidth 1200
/vision config captureJpegQuality 75

STT transcribes incorrectly

Set the correct language explicitly:

/vision config language es   # for Spanish
/vision config language en   # for English

TTS speaks too slowly / wrong voice

Change voice (OpenAI TTS):

/vision config ttsVoice nova   # or alloy, echo, fable, onyx, shimmer