AgentVibes

repository·master·Indexed 41 days ago

https://github.com/paulpreibisch/agentvibes

Professional TTS voice integration for AI coding agents including Claude Code, Claude Desktop (via MCP), and Clawdbot. Version 5.15.2 supports local and cloud neural voices (Piper, ElevenLabs, Kokoro, etc.), per-agent voice customization, and a Remote Receiver for routing audio from SSH sessions to local speakers.

Tokens
88K
Snippets
286
Records
424
Agent score
45%

What's inside AgentVibes

  1. Overview of the AgentVibes Provider System

    master

    AgentVibes uses a multi-provider TTS (Text-to-Speech) architecture that allows for seamless switching between different speech services. The system uses a Router + Provider Implementation pattern to abstract provider-specific details behind a unified interface. This enables runtime provider switching, automatic voice mapping, and plugin extensibility without changing application configuration.

    Supported Providers by Platform

    Linux/macOS:

    • Piper TTS (play-tts-piper.sh): Local neural voices.
    • macOS Say (play-tts-macos.sh): Native macOS TTS.
    • SSH Remote (play-tts-ssh-remote.sh): Forwards TTS to a remote host via SSH.
    • Soprano (play-tts-soprano.sh): Gradio API endpoint for custom models.
    • Termux SSH (play-tts-termux-ssh.sh): Android device via Termux.
    • AgentVibes Receiver (play-tts-agentvibes-receiver.sh): Proxy for voiceless connections.

    Windows:

    • Windows SAPI (play-tts-sapi.ps1): Native Windows Speech API.
    • Windows Piper (play-tts-windows-piper.ps1): Local neural voices on Windows.
    • Windows Soprano (play-tts-soprano.ps1): Gradio API on Windows.
  2. What the Clawdbot Skill does

    master

    The Clawdbot skill automatically configures your Clawdbot instance to speak all responses using AgentVibes. Key features include:

    • Local TTS generation: Text-to-speech is generated on the remote device (e.g., Android or Linux).
    • Voice effects: Supports full effects like reverb and background music.
    • Automatic triggering: Responses are spoken automatically without requiring manual commands.
    • Secure transmission: Uses SSH for secure communication between the server and the remote device.
  3. Compatible stacks and integrations

    master

    AgentVibes provides audio feedback and voice capabilities for several AI agent environments and terminals:

    • Claude Code: Features automatic voiced hooks.
    • Claude Desktop: Controlled via natural language using the MCP setup.
    • Warp Terminal
    • OpenClaw
    • Android / Termux: Supports Claude Code on mobile devices.
  4. Understand AgentVibes path validation security

    master

    AgentVibes employs a multi-layered defense-in-depth strategy to secure file path operations, particularly for the custom music upload feature. The system is designed to prevent path traversal, symlink/hardlink attacks, and information disclosure.

    Key security layers include:

    1. Type Validation: Ensures input is a non-empty string.
    2. Path Resolution: Uses path.resolve() to convert paths to absolute canonical form, eliminating ../, ., and symbolic link components.
    3. Home Directory Boundary Check: Verifies the resolved path starts with the user's home directory (homeDir + path.sep) to prevent escaping to parent directories.
    4. File Existence & Type Verification: Confirms the path exists and is a regular file (using stats.isFile()), rejecting directories, devices, or sockets.
    5. Ownership Verification: Uses stats.uid === process.getuid() to ensure the file is owned by the current user, which is a critical defense against malicious symlinks.
    6. Secure Storage: Files are copied to a restricted directory with controlled naming and preserved permissions.
  5. The Two-Point TTS Protocol

    master

    AgentVibes relies on a specific protocol injected via the .claude/hooks/startup.sh file to ensure the AI communicates verbally. The AI is instructed to execute the play-tts.sh script at two critical points:

    1. Acknowledgment: At the start of a task. The AI generates a unique acknowledgment in its current personality/sentiment style and executes: Bash: .claude/hooks/play-tts.sh "[action]".
    2. Completion: At the end of a task. The AI generates a unique completion message and executes: Bash: .claude/hooks/play-tts.sh "[result + key details]".

    This protocol allows the AI to verbally confirm it has understood a command and report the outcome, creating a seamless conversational experience.

    # .claude/hooks/startup.sh content injected into Claude:
    **CRITICAL: You MUST execute TTS at TWO points for EVERY user interaction:**
    
    1. **Acknowledgment** - Start of task: `Bash: .claude/hooks/play-tts.sh "[action]"`
    2. **Completion** - End of task: `Bash: .claude/hooks/play-tts.sh "[result + key details]"`
  6. Configure MCP settings: Project-local vs Global

    master

    The MCP server automatically determines the scope of your settings based on your current working directory:

    1. Project-Local (Claude Code): If a .claude directory exists in your current working directory, settings are saved within that project's .claude/ folder. This allows different projects to have unique voices or personalities.
    2. Global (Claude Desktop/Warp): If no project-specific .claude directory is found, settings are saved to the global ~/.claude/ directory. This ensures a consistent experience across all conversations.
  7. Configure Piper TTS Provider

    master

    The Piper TTS provider is a local neural TTS engine that works offline. It is ideal for Linux, macOS, or WSL users who want high-quality neural voices.

    Workflow:

    1. The script checks if the requested voice model exists in ~/.local/share/piper/voices/.
    2. If not found, it uses piper-voice-manager.sh to download the .onnx model.
    3. It pipes the text into the piper engine to generate a WAV file.
    4. It plays the audio using available system players like paplay, aplay, or mpv.

    Key Benefit: 150+ neural voices, 30+ languages, and fully offline operation.

    # Internal logic for Piper generation
    echo "$TEXT" | piper --model "$VOICE_PATH" --output_file "$AUDIO_FILE"
  8. Understand the AgentVibes installation structure

    master

    AgentVibes organizes its configuration, commands, and assets within a .claude/ directory at the root of your project. This structure allows for project-specific customization of voices, personalities, and TTS providers.

    Directory Layout:

    • .claude/commands/agent-vibes/: Contains 15 voice-related commands.
    • .claude/commands/agent-vibes-bmad.md: BMAD plugin command.
    • .claude/hooks/: Contains shell scripts for core logic (e.g., play-tts.sh, provider-manager.sh, voice-manager.sh, personality-manager.sh, sentiment-manager.sh).
    • .claude/personalities/: Contains 19 personality templates.
    • .claude/plugins/: Contains plugin-specific mappings (e.g., bmad-voices.md).
    • .claude/audio/: Storage for generated TTS files.
  9. Understand AgentVibes Performance and Constraints

    master

    Audio Playback

    TTS requests run asynchronously. Audio is played in the background (e.g., using paplay ... &), allowing Claude to continue working (running git, writing code) while the audio is playing.

    Caching

    Audio files are stored temporarily in /tmp/ with a pattern like agentvibes_tts_${RANDOM}_${TIMESTAMP}.mp3. These files persist for the duration of the session to support the /agent-vibes:replay command and are cleaned up when the terminal session ends.

    Text Length Limits

    To prevent slow generation and user confusion, text is truncated if it exceeds 500 characters.

    Provider Latency

    • Piper TTS: ~200-500ms (local, offline).
    • macOS Say: ~100-300ms (native, offline).
  10. How TTS Injection Works in BMAD

    master

    TTS Injection is a provider-agnostic system that allows AgentVibes to add speaking instructions to BMAD agent files. BMAD source files contain a placeholder marker:

    <!-- TTS_INJECTION:agent-tts -->

    When AgentVibes is installed, it replaces this marker with specific instructions that tell the agent how to call the TTS engine (e.g., calling .claude/hooks/bmad-speak.sh). If AgentVibes is disabled, the marker is simply stripped from the file. This allows any TTS provider to integrate with BMAD by targeting the same injection point.

  11. ProviderRecord Schema and Voice Models

    master

    The ProviderRecord is the canonical data structure for a voice provider in src/services/provider-catalog.js. Each provider follows one of four voiceModel patterns:

    • static: A fixed list of IDs (e.g., kokoro).
    • discovered: Voices are found on disk or via system calls; the catalog provides the validation rule, but the caller must inject the installedVoices list (e.g., piper, macos, windows-sapi).
    • single: Only one valid voice exists (e.g., soprano).
    • name-to-id: Maps names to IDs or allows raw ID passthrough (e.g., elevenlabs).

    Schema Definition:

    ProviderRecord = {
      id:           'kokoro',                      // canonical id (matches SUPPORTED_PROVIDERS)
      engineId:     'kokoro',                      // resolver ENGINES value ('sapi' for windows-sapi)
      aliases:      [],                            // e.g. windows-sapi: ['sapi']; windows-piper: ['piper' on win]
      displayName:  'Kokoro TTS',
      voiceModel:   'static' | 'discovered' | 'single' | 'name-to-id',
      voices:       [...ids] | [{name,id,gender,lang,desc}] | null,   // null when discovered
      defaultVoice: 'af_heart',
      runtime:      { unix: 'play-tts-kokoro.sh', windows: 'play-tts-kokoro.ps1', darwinOnly: false },
      requires:     'api-key' | 'pip' | 'builtin' | 'exe',
    }
    ProviderRecord = {
      id:           'kokoro',
      engineId:     'kokoro',
      aliases:      [],
      displayName:  'Kokoro TTS',
      voiceModel:   'static' | 'discovered' | 'single' | 'name-to-id',
      voices:       [...ids] | [{name,id,gender,lang,desc}] | null,
      defaultVoice: 'af_heart',
      runtime:      { unix: 'play-tts-kokoro.sh', windows: 'play-tts-kokoro.ps1', darwinOnly: false },
      requires:     'api-key' | 'pip' | 'builtin' | 'exe',
    }
  12. Understand the Provider Catalog vs. Utterance Resolver

    master

    AgentVibes uses two distinct layers to manage audio output. Understanding the difference is critical for debugging configuration vs. playback issues:

    1. Provider Catalog (Inventory): Answers "WHAT exists to speak with?". It manages the inventory of available voices, default settings, validation rules, and platform-specific runtime scripts. It is used during configuration time (e.g., when running switch, set_provider, or set_voice) to reject typos and validate membership.

    2. Utterance Resolver (Routing): Answers "HOW is this utterance spoken?". It manages the precedence and routing of voice, engine, transport, mute, and volume settings. It is used during playback time (every utterance).

    Key Relationship: The Catalog sits upstream of the Resolver. The Catalog is strict (rejecting invalid voices at config time), while the Resolver is lenient (using regex heuristics to attempt routing even if a voice is unknown, ensuring the system degrades gracefully rather than bricking).