Multimodal desktop screen & webcam vision bridge connecting SillyTavern and MateEngine VRM avatars via Google Gemini APIs.
Quick Start · Architecture · Configuration · Privacy & Hardware
AlphaVision Bridge turns a desktop MateEngine VRM companion into a live-vision, screen-aware entity synchronized with SillyTavern. Rather than relying on stale window-title guesses, AlphaVision streams separate sharp screen (1600×900), webcam (640×480), and active-window/cursor ROI crops directly to Google Gemini via a persistent HTTP client—driving spontaneous desktop remarks on delta events and full multimodal conversation on demand.
flowchart LR
subgraph Input["Perception Layer (OpenCV + MediaPipe + MSS)"]
CAM["Webcam 640x480\n(CLAHE Low-Light)"]
SCR["Screen 1600x900\n+ Cursor ROI 768x512"]
WIN["Win32 Window / Idle\n+ Pixel Delta Gate"]
end
subgraph Core["AlphaVision-Bridge (Python :5001)"]
MEM["In-Memory JPEG Buffers\n(io.BytesIO, Zero Disk I/O)"]
BRAIN["BrainEngine\nHysteresis + 90s Cooldown"]
FAST["FastGeminiClient\nKeep-Alive TLS Pool"]
end
subgraph Cloud["Google Gemini API"]
GEM["Gemini Multimodal API\n(User-Supplied API Key)"]
end
subgraph Clients["Avatar & Chat Endpoints"]
ST["SillyTavern :8000\nChat History & Persona"]
ME["MateEngine VRM :8787\nSpeech Bubbles & HUD"]
end
CAM --> MEM
SCR --> MEM
WIN --> BRAIN
MEM --> BRAIN
BRAIN --> FAST
FAST --> GEM
GEM --> FAST
FAST <--> ST
FAST --> ME
ST <--> ME
style Input fill:#0d1117,stroke:#00f0ff,color:#e6edf3
style Core fill:#0d1117,stroke:#bc8cff,color:#e6edf3
style Cloud fill:#0d1117,stroke:#ff2a6d,color:#e6edf3
style Clients fill:#0d1117,stroke:#3fffa8,color:#e6edf3
- Separate High-Detail Frames: Sends sharp desktop captures (
1600×900), clean webcam frames (640×480with automatic CLAHE low-light boost), and focused cursor/window ROI crops (768×512) as distinct multimodal parts—never crushed together in one downscaled thumbnail. - Pixel-Delta Attention Engine (
engine/brain.py): Perceptual diff triggers react immediately to red terminal tracebacks, tab switches, or webcam movement while skipping API calls completely when the workspace is static. - Always-On Multimodal Chat (
AnimeVision.py): OpenAI-compatible/v1/chat/completionsbridge supporting both standard JSON andstream: trueSSE responses with recent spontaneous remarks injected into short-term context. - Unity Runtime Bridge (
unity_bridge_mod/):dnlibIL patcher adding dual-schema/api/chatsupport, liveSPONTANEOUS REMARKSsettings toggle sync inside MateEngine'sGENERALmenu, and viewport-aware TextMeshPro scroll clipping.
- Windows 10 / 11 (Win32 DWM & DirectShow APIs for screen/webcam capture)
- Python 3.10+
- Google Gemini API Key (Google AI Studio)
- SillyTavern & MateEngine (with
unity_bridge_modpatch for desktop overlay)
# 1. Clone the repository & install pinned Python dependencies
git clone https://github.com/antrikshidk/AlphaVision-Bridge.git
cd AlphaVision-Bridge
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
# 2. Configure your local environment (copy templates)
Copy-Item .env.example .env
Copy-Item config.example.json config.json
# Edit .env and set GEMINI_API_KEY (plus optional MATEENGINE_DIR / SILLYTAVERN_DIR)
# 3. Run the bridge
python AnimeVision.pyOptional: SillyTavern Extension, Unity DLL Patch & One-Click Watchdog
- SillyTavern Extension & Server Plugin:
- Copy
extensions/Extension-MateEngine/intoSillyTavern/public/scripts/extensions/third-party/Extension-MateEngine/. - Copy
extensions/mateengine-chat-plugin/intoSillyTavern/plugins/mateengine-chat-plugin/. - Point SillyTavern's OpenAI-compatible API endpoint to
http://127.0.0.1:5001/v1.
- Copy
- MateEngine DLL Patch:
powershell -ExecutionPolicy Bypass -File .\unity_bridge_mod\patch_mateengine_dll.ps1 ` -DnlibPath "C:\path\to\dnlib.dll" ` -MateEngineDir "C:\path\to\MateEngine"
- Headless Watchdog Launch: Run
start_alphavision.bat/launch_alphavision.batto start SillyTavern, AlphaVision, and MateEngine together, orStop_AlphaVision.batto stop all services cleanly.
Copy .env.example to .env (and optionally config.example.json to config.json). Both .env and config.json are gitignored so keys and local directory paths stay strictly on your machine.
| Variable | Default | Purpose |
|---|---|---|
GEMINI_API_KEY |
(required) | Your personal Google AI Studio key |
MODEL_NAME |
gemini-2.5-flash-lite |
Multimodal model for chat & brain engine |
USER_NAME |
User |
Display name referenced in companion prompts |
FLASK_PORT |
5001 |
AlphaVision Flask HTTP bridge port |
MATEENGINE_PORT |
8787 |
MateEngine Unity local HTTP bridge port |
SILLYTAVERN_PORT |
8000 |
SillyTavern web client port |
MATEENGINE_DIR |
(optional) | MateEngine folder for supervisor.ps1 & patcher |
SILLYTAVERN_DIR |
../SillyTavern-Launcher/SillyTavern |
SillyTavern directory for supervisor.ps1 |
- Zero Third-Party Telemetry: AlphaVision runs 100% locally on
127.0.0.1(:5001,:8000,:8787). Captured screen regions and webcam frames are encoded purely in RAM (io.BytesIO, zero disk image writes) and sent exclusively to Google's Gemini endpoint under your ownGEMINI_API_KEY. - Camera Fail-Safe: Works cleanly without a webcam attached (
CameraWorkerfalls back to screen + Win32 window telemetry automatically). - Cursor-Safe Screen Capture: Suppresses Win32
CAPTUREBLT(mss.windows.CAPTUREBLT = 0) so DWM never flickers your hardware mouse cursor.
Run the offline unit test suite (mocks Gemini, webcam, and Unity sockets—no API key or hardware required):
$env:GEMINI_API_KEY = "offline-test-key"
.\.venv\Scripts\python.exe test_awareness.pySee CHANGELOG.md for release history and CONTRIBUTING.md for development guidelines.
Built by antrikshidk · Licensed under AGPL-3.0


