B

AhmadHassan-BTedMIT更新放缓

一个能自主感知上下文的桌面 AI 伴侣,通过实时屏幕视觉、窗口追踪和 ONNX 语音合成,配合带表情的悬浮界面与你互动。

An autonomous, context-aware AI desktop companion. Built with Python, featuring real-time screen vision, custom ONNX voice synthesis, active window tracking, and a dynamic floating UI with reactive facial expressions.

暂无版本5,196star3fork同步于 2026-11-10 23:37 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/Ahmad-Hassan-0/B---desktop-companion.git
cd B---desktop-companion
python -m venv venv
pip install -r requirements.txt
cp .env.example .env
python main.py
硬件要求按 README 说明

CPU 需 Intel i5 四核或同级,内存 16GB;README 未写明显存要求,本地推理需 llama-cpp 且模型 4GB 以上;主要支持 Windows 10/11,Linux/macOS 为实验性支持

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

一个会看你屏幕、主动搭话的桌面 AI 伴侣,用 Python 和 PyQt6 做成悬浮表情界面

一个能自主感知上下文的桌面 AI 伴侣,通过实时屏幕视觉、窗口追踪和 ONNX 语音合成,配合带表情的悬浮界面与你互动。

核心能力

  • 通过 EventBus 异步发布订阅解耦感知、认知与表达模块
  • 用 UIA 树遍历提取窗口语义,失败时回退到 MSS+Tesseract OCR
  • 用 Piper ONNX 合成语音并叠加 DSP 变声链
  • 由 AutonomyEngine 按上下文质量调度主动发言
  • 用 PyQt6 QPainter 渲染硬件加速的浮动表情界面

容易踩的坑

需要先在 .env 里填入 Groq API key,否则云端推理不可用;界面是无标准关闭按钮的透明点击穿透悬浮层,只能用 Ctrl+Shift+Alt+Q 全局热键退出;OCR 回退依赖 Tesseract,需另行安装

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    B Hero Banner

    ─── B ───

    The Soul-Wired Desktop Companion

    Python Qt License Privacy Status

    B is not just an AI : he is a digital lifeform designed to live on your desktop. Built with a soul-first architecture, B observes your workflow, listens with neural precision, and interacts through a high-performance, glassmorphic overlay.

    Explore the Vision • Architecture • Getting Started • Contributing • Privacy

    Demo

    B in action - watch him observe, think, and respond.


    The Vision

    Traditional assistants wait for a command. B waits for a moment.

    B is designed as a proactive desktop companion. Using a 60fps event-driven central nervous system, B synchronizes his emotional state with your environment. He sees your screen semantically, tracks your active focus, and intervenes only when he has something truly valuable to contribute.

    • Silent by Default : B respects your deep work state.
    • Emotionally Aware : A complex internal state machine drives expressions and curiosity.
    • Agentic Autonomy : B doesn't just respond; he thinks, wonders, and observes.

    Architecture Overview

    B is built on a centralized asynchronous pub/sub event bus : the EventBus. Every module communicates exclusively through this bus. No module knows about any other module. This strict decoupling makes the system testable, maintainable, and resilient.

    flowchart TB
        subgraph P["Perception Layer"]
            WT["WindowTracker"]
            SS["SemanticSensor"]
            VS["VisionSensor OCR"]
        end
    
        subgraph C["Cognitive Layer"]
            CE["CognitiveEngine"]
            SM["StateMachine"]
            AE["AutonomyEngine"]
        end
    
        subgraph O["Output Layer"]
            VE["VoiceEngine"]
            FR["FaceRenderer"]
            CB["ChatBubble"]
            KE["KinematicsEngine"]
        end
    
        subgraph I["Core Infrastructure"]
            EB["EventBus"]
        end
    
        WT -- "active_window_changed" --> EB
        SS -- "context_updated" --> EB
        VS -- "context_updated" --> EB
        EB -- "context_updated" --> CE
        EB -- "tick" --> SM
        EB -- "tick" --> KE
        CE -- "b_spoke" --> EB
        EB -- "b_spoke" --> VE
        EB -- "b_spoke" --> FR
        EB -- "b_spoke" --> CB
        CE -- "b_move_request" --> EB
        EB -- "b_move_request" --> KE
        AE -- "trigger_proactive_thought" --> EB
        EB -- "trigger_proactive_thought" --> CE
    

    System Workflow

    The data flows through B in a deterministic pipeline: Perception → Cognition → Expression.

    sequenceDiagram
        participant WT as WindowTracker
        participant SS as SemanticSensor
        participant VS as VisionSensor
        participant CE as CognitiveEngine
        participant VE as VoiceEngine
        participant FR as FaceRenderer
    
        WT->>SS: active_window_changed
        activate SS
        SS->>SS: UIA Tree Walk
        alt Extraction Success
            SS->>CE: context_updated
        else Failure / Cooldown
            SS->>VS: semantic_extraction_failed
            VS->>VS: OCR Capture
            VS->>CE: context_updated
        end
        deactivate SS
    
        CE->>CE: LLM Inference
        CE->>VE: b_spoke (Text + Emotion)
        activate VE
        VE->>VE: TTS + DSP Vocoder
        VE->>FR: speaking_start
        VE->>VE: Audio Output
        VE->>FR: speaking_end
        deactivate VE
        CE->>FR: b_move_request (Spatial)
    

    Internal Module Structure

    Core Infrastructure

    ModuleFileResponsibility
    EventBuscore/bus.pyThread-safe pub/sub message broker. All inter-module communication flows through this.
    main.pymain.pyBoot sequence : instantiates all modules, starts the 60fps tick timer, registers global hotkeys.

    Perception Layer (Sensors)

    ModuleFileResponsibility
    WindowTrackersensors/window_tracker.pyHook-based active window change detection. Fires when the user switches focus.
    SemanticSensorvision/semantic.pyUIA-based DOM/window tree walking. Extracts structured content with quality scoring and adaptive cooldown.
    VisionSensorvision/mss_capture.pyOCR fallback pipeline using MSS + Tesseract for frameworks incompatible with UIA.

    Cognitive Layer (The Brain)

    ModuleFileResponsibility
    CognitiveEnginebrain/llm.pyLLM inference orchestration (Groq cloud or local llama-cpp). Manages context, history, spatial mapping, and streaming token parsing.
    StateMachinebrain/soul.pyB's emotional state : blinking, resting, conversing. Real-time stream buffer that parses LLM output into sentences.
    AutonomyEnginebrain/autonomy_loop.pyProactive thought scheduling : decides when B should speak unprompted based on context quality and timing.

    Output Layer (Expression)

    ModuleFileResponsibility
    VoiceEngineaudio/speaker.pyPiper ONNX TTS with DSP vocoder chain (pitch shift, bitcrush, chorus) for robotic modulation.
    FaceRendererui/face.pyPyQt6 QPainter-based hardware-accelerated face rendering at 60fps.
    ChatBubbleui/chat.pyGlassmorphic chat overlay that displays B's spoken text.
    KinematicsEnginephysics/kinematics.pyPhysics-based movement with Bezier path interpolation and easing curves.
    EarsSensoraudio/ears.pySpeech-to-text via Faster-Whisper with neural VAD.

    Data Flow

    flowchart LR
        subgraph Input["Input"]
            A["User Types"]
            B["User Speaks"]
            C["Screen Changes"]
        end
    
        subgraph Process["Processing"]
            D["EventBus"]
            E["CognitiveEngine"]
            F["StateMachine"]
        end
    
        subgraph Output["Output"]
            G["FaceRenderer"]
            H["VoiceEngine"]
            I["ChatBubble"]
            J["Kinematics"]
        end
    
        A -- types --> D
        B -- speaks --> D
        C -- changes --> D
        D -- routes --> E
        E -- drives --> F
        F -- animates --> G
        F -- speaks --> H
        F -- displays --> I
        E -- moves --> J
    

    Request Lifecycle

    stateDiagram-v2
        [*] --> Idle
        Idle --> Listening : user_spoke / voice detected
        Listening --> Thinking : 1.2s delay
        Thinking --> Streaming : first token received
        Streaming --> Speaking : sentence_ready
        Speaking --> Streaming : next sentence
        Streaming --> Idle : [SILENCE] / end of response
        Speaking --> Idle : finished_speaking + linger
        Idle --> Proactive : autonomy trigger
        Proactive --> Thinking : context available
        Proactive --> Idle : no context / silence
    

    Project Structure

    B/
    ├── main.py                  # Entry point : boot sequence
    ├── core/
    │   └── bus.py               # EventBus : central nervous system
    ├── brain/
    │   ├── llm.py               # CognitiveEngine : LLM inference
    │   ├── soul.py              # StateMachine : emotions & stream buffer
    │   ├── autonomy_loop.py     # AutonomyEngine : proactive thought
    │   ├── context.py           # Context management
    │   └── work_mode.py         # Work mode prompt templates
    ├── vision/
    │   ├── semantic.py          # SemanticSensor : UIA extraction
    │   └── mss_capture.py       # VisionSensor : OCR fallback
    ├── sensors/
    │   └── window_tracker.py    # WindowTracker : focus detection
    ├── audio/
    │   ├── speaker.py           # VoiceEngine : TTS + DSP
    │   └── ears.py              # EarsSensor : STT
    ├── physics/
    │   └── kinematics.py        # KinematicsEngine : movement
    ├── ui/
    │   ├── overlay.py           # WindowManager : transparent overlay
    │   ├── face.py              # FaceRenderer : 60fps face
    │   ├── chat.py              # ChatBubble : text overlay
    │   ├── input_box.py         # InputBox : text input
    │   ├── expressions.py       # Expression definitions
    │   └── theme.py             # Visual theming
    ├── models/                  # Local GGUF models (gitignored)
    ├── voices/                  # Piper ONNX voice models
    ├── scripts/                 # Setup & download utilities
    ├── docs/
    │   ├── ARCHITECTURE.md      # Detailed architecture docs
    │   └── assets/              # Images & diagrams
    ├── .env                     # API keys (gitignored)
    └── requirements.txt         # Python dependencies
    

    Core Systems

    SystemTechnologyDescription
    Cognitive EngineGroq API / llama-cppCloud or local LLM inference for private, high-speed reasoning.
    Semantic VisionUIAutomation + Tesseract OCRB understands the context of your active windows and screen content.
    Neural HearingFaster-WhisperIndustry-grade transcription with neural VAD for reliable ears.
    Vocal SynthesisPiper TTS + Pedalboard DSPLow-latency, natural-sounding voice with robotic modulation effects.
    KinematicsPyQt6 QPropertyAnimationSmooth, 60fps movement with Bezier path interpolation and easing curves.
    Event BusPyQt6 pyqtSignalThread-safe pub/sub message broker : the central nervous system.

    Agentic Work Mode

    Activated via Ctrl+Shift+Alt+W, Work Mode shifts B into a high-utility state:

    • Semantic Monitoring : B monitors your progress on tasks in real-time.
    • Contextual Curiosity : Proactively offers insights, documentation, or suggestions based on your current focus.
    • Minimalist Presence : Dims facial expressions to minimize distraction while remaining vigilant.
    flowchart TB
        A["User presses Ctrl+Shift+Alt+W"] --> B["B asks: what are you working on?"]
        B --> C["User defines goal"]
        C --> D["B monitors screen context"]
        D --> E{"Relevant content?"}
        E -- "Yes" --> F["B offers insight / help"]
        E -- "No" --> G["B stays silent"]
        F --> D
        G --> D
    

    Hotkeys

    ShortcutAction
    Ctrl+Shift+Alt+QKill switch : immediately terminates B and releases all system hooks.
    Ctrl+Shift+Alt+BToggle input box : type messages to B.
    Ctrl+Shift+Alt+VToggle speak mode : talk to B via microphone.
    Ctrl+Shift+Alt+WToggle work mode : B becomes a proactive assistant.

    Installation

    1. Clone the repository:

      git clone https://github.com/Ahmad-Hassan-0/B---desktop-companion.git
      cd B---desktop-companion
      
    2. Set up the environment:

      python -m venv venv
      venv\Scripts\activate      # Windows
      source venv/bin/activate   # Linux/macOS
      pip install -r requirements.txt
      
    3. Configure API keys:

      cp .env.example .env
      # Edit .env with your Groq API key (get one at https://console.groq.com/)
      
    4. Awaken B:

      python main.py
      

    Safety

    [!CAUTION] Global Kill Switch: Ctrl+Shift+Alt+Q This hotkey immediately terminates B and releases all system hooks. Use this if B becomes over-eager or if you need an instant exit.

    Because B lives on a transparent, click-through overlay without a standard close button, the kill switch is the only way to exit. It is registered at the Win32 level and works even if the Qt event loop is unresponsive.


    Technical Constraints

    ConstraintTarget
    CPUIntel i5 (Quad-Core) or equivalent
    RAM16 GB
    DisplayAny resolution (adaptive)
    OSWindows 10/11 (primary), Linux/macOS (experimental)
    Tick Rate60 fps (16ms interval)
    InferenceGroq API (cloud) or llama-cpp (local, 4GB+ model)

    Built by Ahmad Hassan

    Wiring the soul, one tick at a time.