⛰️ LifeOS — The AI-powered Life Operating System that helps you hill climb to wherever you're going.
Complete refactor: ElevenLabs to native macOS voices + voice config system
Daniel Miessler275678e6e3ec
diff --git a/PAI_DIRECTORY/documentation/VOICE-SETUP-GUIDE.md b/PAI_DIRECTORY/documentation/VOICE-SETUP-GUIDE.mdindex e06606e8..353bf2d1 100644--- a/PAI_DIRECTORY/documentation/VOICE-SETUP-GUIDE.md+++ b/PAI_DIRECTORY/documentation/VOICE-SETUP-GUIDE.md@@ -14,24 +14,24 @@ This guide will walk you through setting up high-quality, natural-sounding voice1. Click the **Apple menu** () in the top-left corner of your screen2. Click **System Settings** (it has a gear icon ⚙️)-3. In the sidebar on the left, scroll down until you see **Accessibility**-4. Click **Accessibility**+3. In the sidebar on the left, scroll down until you see **Voice (Live Speech)**+4. Click **Voice (Live Speech)****What you'll see:**-A window with a sidebar containing many categories. Accessibility should be near the bottom of the list.+A window with voice and speech-related settings including spoken content options.-### Step 2: Navigate to Spoken Content+### Step 2: Access Voice Management-1. In the Accessibility section, look for **Spoken Content** in the right panel- - It might be under a "Hearing" or "Speech" category depending on your macOS version- - On some versions, you might need to scroll down the right panel to find it+1. Look for the **System voice** dropdown menu+ - It should be near the top of the Voice settings panel+ - Shows the currently selected system voice-2. Click **Spoken Content**+2. Click on the **System voice** dropdown**What you'll see:**-A panel with options like "Speak selection", "Speak screen", and **"System voice"** dropdown menu.+A dropdown menu showing currently installed voices.-### Step 3: Access Voice Management+### Step 3: Download Premium Voices1. Find the **System voice** dropdown (it's usually near the top)2. Click on the dropdown - you'll see a list of currently installed voices@@ -293,7 +293,7 @@ When you use Kai or ask an agent to do something:**Cause:** You downloaded the wrong voice (Compact/Legacy instead of Premium/Enhanced)**Solution:**-1. Go back to System Settings → Accessibility → Spoken Content → Manage Voices+1. Go back to System Settings → Voice (Live Speech) → Manage Voices2. Make sure you're downloading voices labeled **(Premium)** or **(Enhanced)**3. Voices without these labels are old and robotic - don't use them!diff --git a/PAI_DIRECTORY/documentation/voice-system.md b/PAI_DIRECTORY/documentation/voice-system.mdindex 753ad62d..2f3adcb7 100644--- a/PAI_DIRECTORY/documentation/voice-system.md+++ b/PAI_DIRECTORY/documentation/voice-system.md@@ -83,6 +83,51 @@ All entities use high-quality macOS Premium or Enhanced neural voices for natura## Server Configuration+### Voice Configuration (voices.json)++The voice system uses a centralized JSON configuration file for all voice and speed settings:++**Location:** `~/.claude/voice-server/voices.json`++**Structure:**+```json+{+ "default_rate": 175,+ "voices": {+ "kai": {+ "voice_name": "Jamie (Premium)",+ "rate_multiplier": 1.3,+ "rate_wpm": 228,+ "description": "UK Male - Professional, conversational",+ "type": "Premium"+ },+ "researcher": {+ "voice_name": "Ava (Premium)",+ "rate_multiplier": 1.35,+ "rate_wpm": 236,+ "description": "US Female - Analytical, highest quality",+ "type": "Premium"+ }+ }+}+```++**Configuration Fields:**+- `voice_name`: macOS voice name (e.g., "Jamie (Premium)", "Ava (Premium)")+- `rate_multiplier`: Speed multiplier (1.0 = normal, 1.3 = 30% faster)+- `rate_wpm`: Words per minute (calculated as default_rate × rate_multiplier)+- `description`: Human-readable description of the voice+- `type`: Voice quality level (Premium or Enhanced)++**Customizing Voice Speeds:**+To change speech rates, edit the `rate_multiplier` or `rate_wpm` values in voices.json:+- Kai (default): 1.3x = 228 wpm+- Agents (default): 1.35x = 236 wpm+- Normal speed: 1.0x = 175 wpm+- Fast speed: 1.5x = 263 wpm++Changes take effect immediately (no server restart required for hook-initiated voices).+### Environment Variables (in ~/.env)```bashPORT="8888" # Optional, defaults to 8888@@ -176,7 +221,7 @@ Voices are selected based on:### How to Add More Premium/Enhanced Voices1. Open **System Settings**-2. Navigate to **Accessibility** → **Spoken Content**+2. Navigate to **Voice (Live Speech)**3. Click **System Voice** dropdown4. Select **Manage Voices...**5. Download desired Premium or Enhanced voices@@ -315,14 +360,20 @@ curl -X POST http://localhost:8888/notify \### Adding New Voices-1. Download voice via System Settings-2. Update stop-hook.ts VOICES mapping:- ```typescript- const VOICES = {- kai: "Jamie (Premium)",- researcher: "Ava (Premium)",- newagent: "NewVoice (Premium)" // Add here- };+1. Download voice via System Settings → Voice (Live Speech) → Manage Voices+2. Update voices.json configuration:+ ```json+ {+ "voices": {+ "newagent": {+ "voice_name": "NewVoice (Premium)",+ "rate_multiplier": 1.35,+ "rate_wpm": 236,+ "description": "Description of voice",+ "type": "Premium"+ }+ }+ }```3. Update agent frontmatter:diff --git a/PAI_DIRECTORY/hooks/context-compression-hook.ts b/PAI_DIRECTORY/hooks/context-compression-hook.tsindex 4f331b9d..21fc4056 100755--- a/PAI_DIRECTORY/hooks/context-compression-hook.ts+++ b/PAI_DIRECTORY/hooks/context-compression-hook.ts@@ -5,14 +5,31 @@*/import { readFileSync } from 'fs';+import { join } from 'path';+import { homedir } from 'os';interface NotificationPayload {title: string;message: string;voice_enabled: boolean;+ voice_name?: string;+ rate?: number;priority?: 'low' | 'normal' | 'high';}+interface VoiceConfig {+ voice_name: string;+ rate_wpm: number;+ rate_multiplier: number;+ description: string;+ type: string;+}++interface VoicesConfig {+ default_rate: number;+ voices: Record<string, VoiceConfig>;+}+interface HookInput {session_id: string;transcript_path: string;@@ -82,6 +99,23 @@ function getTranscriptStats(transcriptPath: string): { messageCount: number; isL}}+// Load voice configuration+let kaiVoiceConfig: VoiceConfig;+try {+ const voicesPath = join(homedir(), 'Library/Mobile Documents/com~apple~CloudDocs/Claude/voice-server/voices.json');+ const config: VoicesConfig = JSON.parse(readFileSync(voicesPath, 'utf-8'));+ kaiVoiceConfig = config.voices.kai;+} catch (e) {+ // Fallback to hardcoded Kai voice config+ kaiVoiceConfig = {+ voice_name: "Jamie (Premium)",+ rate_wpm: 263,+ rate_multiplier: 1.5,+ description: "UK Male",+ type: "Premium"+ };+}+async function main() {let hookInput: HookInput | null = null;@@ -130,11 +164,13 @@ async function main() {}}- // Send notification with voice+ // Send notification with voice (using Kai's voice from config)await sendNotification({title: 'Kai Context',message: message,voice_enabled: true,+ voice_name: kaiVoiceConfig.voice_name,+ rate: kaiVoiceConfig.rate_wpm,priority: 'low',});diff --git a/PAI_DIRECTORY/hooks/stop-hook.ts b/PAI_DIRECTORY/hooks/stop-hook.tsindex 13c41a7c..8182077e 100755--- a/PAI_DIRECTORY/hooks/stop-hook.ts+++ b/PAI_DIRECTORY/hooks/stop-hook.ts@@ -1,6 +1,8 @@#!/usr/bin/env bunimport { readFileSync } from 'fs';+import { join } from 'path';+import { homedir } from 'os';/*** Generate 4-word tab title summarizing what was done@@ -128,17 +130,41 @@ function setTerminalTabTitle(title: string): void {}}-// Voice differentiation using high-quality Premium and Enhanced macOS voices-// Mix of US, UK, and Indian accents for variety-const VOICES = {- kai: "Jamie (Premium)", // UK Male - professional, conversational- researcher: "Ava (Premium)", // US Female - analytical, highest quality- engineer: "Tom (Enhanced)", // US Male - steady, professional- architect: "Serena (Premium)", // UK Female - strategic, sophisticated- designer: "Isha (Premium)", // Indian Female - creative, distinct- pentester: "Oliver (Enhanced)", // UK Male - technical, sharp- writer: "Samantha (Enhanced)" // US Female - articulate, warm-};+// Load voice configuration from voices.json+interface VoiceConfig {+ voice_name: string;+ rate_wpm: number;+ rate_multiplier: number;+ description: string;+ type: string;+}++interface VoicesConfig {+ default_rate: number;+ voices: Record<string, VoiceConfig>;+}++// Load voices configuration+let VOICE_CONFIG: VoicesConfig;+try {+ const voicesPath = join(homedir(), 'Library/Mobile Documents/com~apple~CloudDocs/Claude/voice-server/voices.json');+ VOICE_CONFIG = JSON.parse(readFileSync(voicesPath, 'utf-8'));+} catch (e) {+ // Fallback to hardcoded config if file doesn't exist+ console.error('⚠️ Could not load voices.json, using fallback config');+ VOICE_CONFIG = {+ default_rate: 175,+ voices: {+ kai: { voice_name: "Jamie (Premium)", rate_wpm: 263, rate_multiplier: 1.5, description: "UK Male", type: "Premium" },+ researcher: { voice_name: "Ava (Premium)", rate_wpm: 236, rate_multiplier: 1.35, description: "US Female", type: "Premium" },+ engineer: { voice_name: "Tom (Enhanced)", rate_wpm: 236, rate_multiplier: 1.35, description: "US Male", type: "Enhanced" },+ architect: { voice_name: "Serena (Premium)", rate_wpm: 236, rate_multiplier: 1.35, description: "UK Female", type: "Premium" },+ designer: { voice_name: "Isha (Premium)", rate_wpm: 236, rate_multiplier: 1.35, description: "Indian Female", type: "Premium" },+ pentester: { voice_name: "Oliver (Enhanced)", rate_wpm: 236, rate_multiplier: 1.35, description: "UK Male", type: "Enhanced" },+ writer: { voice_name: "Samantha (Enhanced)", rate_wpm: 236, rate_multiplier: 1.35, description: "US Female", type: "Enhanced" }+ }+ };+}// Intelligent response generator - prioritizes custom COMPLETED messagesfunction generateIntelligentResponse(userQuery: string, assistantResponse: string, completedLine: string): string {@@ -333,7 +359,7 @@ async function main() {// Generate the announcementlet message = '';- let voiceName = VOICES.kai; // Default to Kai's voice+ let voiceConfig = VOICE_CONFIG.voices.kai; // Default to Kai's voice configlet kaiHasCustomCompleted = false;// ALWAYS check Kai's response FIRST (even when agents are used)@@ -407,7 +433,7 @@ async function main() {const wordCount = customText.split(/\s+/).length;if (customText && wordCount <= 8) {message = customText;- voiceName = VOICES[agentType.toLowerCase()] || VOICES.kai;+ voiceConfig = VOICE_CONFIG.voices[agentType.toLowerCase()] || VOICE_CONFIG.voices.kai;console.error(`🗣️ AGENT CUSTOM VOICE (fallback): ${message}`);} else {// Custom completed too long, fall back to regular COMPLETED@@ -418,7 +444,7 @@ async function main() {.replace(/\[AGENT:\w+\]\s*/i, '').trim();message = generateIntelligentResponse(lastUserQuery, taskResult, completedText);- voiceName = VOICES[agentType.toLowerCase()] || VOICES.kai;+ voiceConfig = VOICE_CONFIG.voices[agentType.toLowerCase()] || VOICE_CONFIG.voices.kai;console.error(`🎯 AGENT FALLBACK (custom too long): ${message}`);}}@@ -438,7 +464,7 @@ async function main() {// Generate intelligent response for agent tasksmessage = generateIntelligentResponse(lastUserQuery, taskResult, completedText);- voiceName = VOICES[agentType.toLowerCase()] || VOICES.kai;+ voiceConfig = VOICE_CONFIG.voices[agentType.toLowerCase()] || VOICE_CONFIG.voices.kai;console.error(`🎯 AGENT INTELLIGENT (fallback): ${message}`);}@@ -447,16 +473,17 @@ async function main() {// FIRST: Send voice notification if we have a messageif (message) {- // Send to voice server+ // Send to voice server with both voice name and speech rateawait fetch('http://localhost:8888/notify', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({message: message,- voice_name: voiceName // Send the macOS voice name+ voice_name: voiceConfig.voice_name,+ rate: voiceConfig.rate_wpm})}).catch(() => {});- console.error(`🔊 Voice notification sent: "${message}" with voice: ${voiceName}`);+ console.error(`🔊 Voice notification sent: "${message}" with voice: ${voiceConfig.voice_name} at ${voiceConfig.rate_wpm} wpm (${voiceConfig.rate_multiplier}x)`);}// ALWAYS set tab title to override any previous titles (like "dynamic requirements")diff --git a/PAI_DIRECTORY/voice-server/README.md b/PAI_DIRECTORY/voice-server/README.mdindex 6b4036aa..996dc1e6 100644--- a/PAI_DIRECTORY/voice-server/README.md+++ b/PAI_DIRECTORY/voice-server/README.md@@ -1,258 +1,326 @@# PAI Voice Server-A voice notification server for the Personal AI Infrastructure (PAI) system that provides text-to-speech notifications using ElevenLabs API or macOS's built-in `say` command as fallback.+A zero-cost voice notification server for the Personal AI Infrastructure (PAI) system that provides text-to-speech notifications using macOS Premium and Enhanced neural voices.-> **Quick Start**: See [QUICKSTART.md](QUICKSTART.md) for a 5-minute setup guide.+> **Quick Start**: See [documentation/VOICE-SETUP-GUIDE.md](../documentation/VOICE-SETUP-GUIDE.md) for detailed setup guide.## 🎯 Features-- **ElevenLabs Integration**: High-quality AI voices for notifications-- **Fallback Support**: Uses macOS `say` command when ElevenLabs is not configured-- **Multiple Voice Support**: Different voices for different AI agents-- **macOS Service**: Runs automatically in the background-- **Menu Bar Indicator**: Visual status indicator in macOS menu bar-- **Simple HTTP API**: Easy integration with any tool or script+- **Native macOS Voices**: Uses Premium and Enhanced neural TTS voices (no API costs)+- **Distinct Voice Personalities**: Different Premium voices for Kai and each agent+- **100% Offline**: No cloud APIs, complete privacy+- **Customizable Speed**: Configurable speech rates for each entity+- **Simple HTTP API**: Easy integration via REST endpoints+- **JSON Configuration**: Centralized voice and speed settings in voices.json## 📋 Prerequisites-- macOS (tested on macOS 11+)+- macOS 13.0 (Ventura) or later (for Premium/Enhanced voices)- [Bun](https://bun.sh) runtime installed-- ElevenLabs API key (optional, for AI voices)+- Premium/Enhanced voices downloaded from System Settings## 🚀 Quick Start-### 1. Install Bun (if not already installed)-```bash-curl -fsSL https://bun.sh/install | bash-```+### 1. Download Premium Voices-### 2. Configure API Key (Optional but Recommended)-Add your ElevenLabs API key to `${PAI_DIR}/.env`:-```bash-echo "ELEVENLABS_API_KEY=your_api_key_here" >> ${PAI_DIR}/.env-echo "ELEVENLABS_VOICE_ID=jqcCZkN6Knx8BJ5TBdYR" >> ${PAI_DIR}/.env-```+1. Open **System Settings**+2. Navigate to **Voice (Live Speech)**+3. Click **System Voice** dropdown → **Manage Voices...**+4. Download these voices:+ - **Jamie (Premium)** - English (UK) - For Kai+ - **Ava (Premium)** - English (US) - For Researcher (highest quality)+ - **Serena (Premium)** - English (UK) - For Architect+ - **Isha (Premium)** - English (India) - For Designer+ - **Tom (Enhanced)** - English (US) - For Engineer+ - **Oliver (Enhanced)** - English (UK) - For Pentester++See [VOICE-SETUP-GUIDE.md](../documentation/VOICE-SETUP-GUIDE.md) for detailed download instructions.-> Get your free API key at [elevenlabs.io](https://elevenlabs.io) (10,000 characters/month free)+### 2. Start the Voice Server-### 3. Install Voice Server```bashcd ${PAI_DIR}/voice-server-./install.sh+bun server.ts &```-This will:-- Install dependencies-- Create a macOS LaunchAgent for auto-start-- Start the voice server on port 8888-- Verify the installation-- Optionally install menu bar indicator (requires SwiftBar/BitBar)+**Expected output:**+```+🚀 PAIVoice Server running on port 8888+🎙️ Using macOS native voices (default: Jamie (Premium))+📡 POST to http://localhost:8888/notify+🔒 Security: CORS restricted to localhost, rate limiting enabled+```-## 🛠️ Service Management+### 3. Test Voice Output-### Start Server```bash-./start.sh-# or-launchctl load ~/Library/LaunchAgents/com.pai.voice-server.plist+curl -X POST http://localhost:8888/notify \+ -H "Content-Type: application/json" \+ -d '{"message":"Voice system working perfectly","voice_name":"Jamie (Premium)","rate":228}'```-### Stop Server-```bash-./stop.sh-# or-launchctl unload ~/Library/LaunchAgents/com.pai.voice-server.plist-```+## 🔧 Configuration-### Restart Server-```bash-./restart.sh+### Voice Configuration (voices.json)++All voice and speed settings are centralized in `voices.json`:++```json+{+ "default_rate": 175,+ "voices": {+ "kai": {+ "voice_name": "Jamie (Premium)",+ "rate_multiplier": 1.3,+ "rate_wpm": 228,+ "description": "UK Male - Professional, conversational",+ "type": "Premium"+ },+ "researcher": {+ "voice_name": "Ava (Premium)",+ "rate_multiplier": 1.35,+ "rate_wpm": 236,+ "description": "US Female - Analytical, highest quality",+ "type": "Premium"+ }+ }+}```-### Check Status-```bash-./status.sh-```+**Customizing Voices and Speeds:**+Edit `voices.json` to change:+- `voice_name`: Any Premium or Enhanced macOS voice+- `rate_multiplier`: Speed (1.0 = normal, 1.3 = 30% faster, 1.5 = 50% faster)+- `rate_wpm`: Words per minute (auto-calculated or set manually)-### Uninstall-```bash-./uninstall.sh-```-This will stop the service and remove the LaunchAgent.+Changes take effect immediately (hooks reload config on each use).++### Environment Variables-## 📡 API Usage+Optional configuration in `${PAI_DIR}/.env`:-### Send a Voice Notification```bash-curl -X POST http://localhost:8888/notify \- -H "Content-Type: application/json" \- -d '{- "message": "Task completed successfully",- "voice_id": "jqcCZkN6Knx8BJ5TBdYR",- "voice_enabled": true- }'+# Server port (optional, defaults to 8888)+PORT=8888```-### Parameters-- `message` (required): The text to speak-- `voice_id` (optional): ElevenLabs voice ID to use-- `voice_enabled` (optional): Whether to speak the notification (default: true)-- `title` (optional): Notification title (default: "PAI Notification")--### Available Voice IDs-```javascript-// PAI System Agents-Kai: jqcCZkN6Knx8BJ5TBdYR // Main assistant-Researcher: AXdMgz6evoL7OPd7eU12 // Research agent-Engineer: kmSVBPu7loj4ayNinwWM // Engineering agent-Designer: ZF6FPAbjXT4488VcRRnw // Design agent-Pentester: hmMWXCj9K7N5mCPcRkfC // Security agent-Architect: muZKMsIDGYtIkjjiUS82 // Architecture agent-Writer: gfRt6Z3Z8aTbpLfexQ7N // Content agent-```+**No API keys required** - voice system is 100% free and offline.-## 🖥️ Menu Bar Indicator+## 📡 API Reference-The voice server includes an optional menu bar indicator that shows the server status.+### POST /notify-### Installing the Menu Bar+Main endpoint for voice notifications.-1. **Install SwiftBar** (recommended) or BitBar:-```bash-brew install --cask swiftbar-# OR-brew install --cask bitbar+**Request:**+```json+{+ "message": "Text to speak",+ "voice_name": "Jamie (Premium)",+ "rate": 228,+ "title": "Optional notification title",+ "voice_enabled": true+}```-2. **Run the menu bar installer**:-```bash-cd ${PAI_DIR}/voice-server/menubar-./install-menubar.sh+**Parameters:**+- `message` (required): Text to be spoken+- `voice_name` (optional): macOS voice name (e.g., "Jamie (Premium)")+- `rate` (optional): Speech rate in words per minute (default: 175)+- `title` (optional): Visual notification title+- `voice_enabled` (optional): Set to false to skip voice output++**Response:**+```json+{+ "status": "success",+ "message": "Notification sent"+}```-### Menu Bar Features-- **Visual Status**: 🎙️ (running) or 🎙️⚫ (stopped)-- **Quick Controls**: Start/Stop/Restart server from menu-- **Status Info**: Shows voice type (ElevenLabs/macOS Say)-- **Quick Test**: Test voice with one click-- **View Logs**: Access server logs directly+### POST /pai-### Manual Installation-If you prefer manual installation:-1. Copy `menubar/pai-voice.5s.sh` to your SwiftBar/BitBar plugins folder-2. Make it executable: `chmod +x pai-voice.5s.sh`-3. Refresh SwiftBar/BitBar+Simplified endpoint using Kai's default voice.-## 🔧 Configuration--### Environment Variables-Create or edit `${PAI_DIR}/.env`:+**Request:**+```json+{+ "title": "PAI System",+ "message": "System message"+}+```-```bash-# Required for ElevenLabs voices (optional)-ELEVENLABS_API_KEY=your_api_key_here+### GET /health-# Default voice ID (optional, defaults to Kai)-ELEVENLABS_VOICE_ID=jqcCZkN6Knx8BJ5TBdYR+Health check endpoint.-# Server port (optional, defaults to 8888)-PORT=8888+**Response:**+```json+{+ "status": "healthy",+ "port": 8888,+ "voice_system": "macOS Native",+ "default_voice": "Jamie (Premium)"+}```-### Finding Your Voice ID-1. Go to [ElevenLabs Voice Library](https://elevenlabs.io/voice-library)-2. Select a voice you like-3. Click "Use" and copy the Voice ID-4. Update `ELEVENLABS_VOICE_ID` in your `${PAI_DIR}/.env`+## 🎙️ Voice Mappings++| Entity | Voice | Type | Speed | Accent | Description |+|--------|-------|------|-------|--------|-------------|+| Kai | Jamie (Premium) | Premium | 1.3x | UK Male | Professional, conversational |+| Researcher | Ava (Premium) | Premium | 1.35x | US Female | Analytical, highest quality |+| Engineer | Tom (Enhanced) | Enhanced | 1.35x | US Male | Steady, professional |+| Architect | Serena (Premium) | Premium | 1.35x | UK Female | Strategic, sophisticated |+| Designer | Isha (Premium) | Premium | 1.35x | Indian Female | Creative, distinct |+| Pentester | Oliver (Enhanced) | Enhanced | 1.35x | UK Male | Technical, sharp |+| Writer | Samantha (Enhanced) | Enhanced | 1.35x | US Female | Articulate, warm |## 🐛 Troubleshooting-### Server won't start+### Server Won't Start+```bash-# Check if port 8888 is already in use+# Check if port 8888 is in uselsof -i :8888# Kill any existing processlsof -ti :8888 | xargs kill -9-# Restart the server-./restart.sh+# Restart server+cd ${PAI_DIR}/voice-server && bun server.ts &```-### No voice output-```bash-# Check if ElevenLabs key is configured-grep ELEVENLABS_API_KEY ${PAI_DIR}/.env+### Voice Sounds Robotic-# Test with fallback (macOS say)-curl -X POST http://localhost:8888/notify \- -H "Content-Type: application/json" \- -d '{"message": "Testing voice output"}'+**Problem:** Downloaded wrong voice type (Compact/Legacy instead of Premium/Enhanced)-# Check server logs-tail -f ~/Library/Logs/pai-voice-server.log-```+**Solution:**+1. Go to System Settings → Voice (Live Speech) → Manage Voices+2. Ensure you're downloading voices labeled **(Premium)** or **(Enhanced)**+3. Voices without these labels are old robotic voices - don't use them!++### Voice Not Found-### Service not auto-starting```bash-# Check LaunchAgent status-launchctl list | grep pai.voice+# Verify voice is downloaded+say -v '?' | grep "Jamie (Premium)"++# If not found, download from System Settings+# System Settings → Voice (Live Speech) → Manage Voices+```++### No Sound Output-# Reload LaunchAgent-launchctl unload ~/Library/LaunchAgents/com.pai.voice-server.plist-launchctl load ~/Library/LaunchAgents/com.pai.voice-server.plist+**Checklist:**+1. System volume not muted+2. Voice server running: `curl http://localhost:8888/health`+3. Voice downloaded: `say -v "Jamie (Premium)" "test"`+4. Correct output device selected (System Settings → Sound)-# Check for errors-tail -f ~/Library/Logs/pai-voice-server.log+### Wrong Voice Playing++```bash+# Check voices.json configuration+cat ${PAI_DIR}/voice-server/voices.json++# Check stop-hook is loading config+grep "VOICE_CONFIG" ~/.claude/hooks/stop-hook.ts```+## 🔐 Security & Privacy++- **100% Local Processing**: All voice generation happens on your Mac+- **Zero Cost**: No cloud APIs, no subscriptions+- **Complete Privacy**: No data sent to external services+- **CORS Protected**: Server only accepts requests from localhost+- **Rate Limited**: 10 requests per minute to prevent abuse+## 📁 File Structure+```${PAI_DIR}/voice-server/-├── server.ts # Main server code-├── install.sh # Installation script-├── start.sh # Start server-├── stop.sh # Stop server-├── restart.sh # Restart server-├── status.sh # Check server status-├── uninstall.sh # Uninstall service-├── README.md # This file-└── menubar/- ├── pai-voice.5s.sh # Menu bar status script- └── install-menubar.sh # Menu bar installer--~/Library/LaunchAgents/-└── com.pai.voice-server.plist # macOS service definition--~/Library/Logs/-└── pai-voice-server.log # Server logs+├── server.ts # Main voice server+├── voices.json # Voice configuration (edit this for customization)+└── README.md # This file++~/.claude/hooks/+├── stop-hook.ts # Triggers voice notifications on completion+└── context-compression-hook.ts # Notification for context compression++~/Library/Mobile Documents/com~apple~CloudDocs/Claude/voice-server/+└── Same structure (if using cloud sync)+```++## 🎬 Usage Examples++### Test Individual Voices++```bash+# Test Kai's voice+curl -X POST http://localhost:8888/notify \+ -H "Content-Type: application/json" \+ -d '{"message":"Testing Kai voice","voice_name":"Jamie (Premium)","rate":228}'++# Test Researcher voice+curl -X POST http://localhost:8888/notify \+ -H "Content-Type: application/json" \+ -d '{"message":"Testing Researcher voice","voice_name":"Ava (Premium)","rate":236}'++# Test Engineer voice+curl -X POST http://localhost:8888/notify \+ -H "Content-Type: application/json" \+ -d '{"message":"Testing Engineer voice","voice_name":"Tom (Enhanced)","rate":236}'```-## 🔐 Security Notes+### Custom Voice Speeds-- **No hardcoded API keys**: All sensitive data is read from `${PAI_DIR}/.env`-- **Local only**: Server only listens on localhost (127.0.0.1)-- **User-specific**: Each user maintains their own API keys-- **Safe for public repos**: No sensitive data in the codebase+```bash+# Slow speed (0.8x = 140 wpm)+curl -X POST http://localhost:8888/notify \+ -H "Content-Type: application/json" \+ -d '{"message":"Slow speed test","voice_name":"Jamie (Premium)","rate":140}'++# Fast speed (1.5x = 263 wpm)+curl -X POST http://localhost:8888/notify \+ -H "Content-Type: application/json" \+ -d '{"message":"Fast speed test","voice_name":"Jamie (Premium)","rate":263}'+```## 🤝 Integration with PAI System-This voice server integrates with the PAI (Personal AI Infrastructure) system to provide voice notifications when:-- Tasks are completed-- Agents finish their work-- Important events occur-- User notifications are needed+The voice server automatically integrates with PAI hooks:++- **stop-hook.ts**: Sends voice notification when Kai or agents complete tasks+- **context-compression-hook.ts**: Announces when conversation context is compacted+- Both hooks load voice configuration from `voices.json`-The PAI hooks automatically send notifications to this server when configured.+No manual integration needed - just start the server and hooks will use it automatically.-## 📝 License+## 📖 Documentation-Part of the PAI (Personal AI Infrastructure) system.+- **[VOICE-SETUP-GUIDE.md](../documentation/VOICE-SETUP-GUIDE.md)** - Complete setup guide+- **[voice-system.md](../documentation/voice-system.md)** - Technical documentation+- **[voices.json](./voices.json)** - Voice configuration file++## 💡 Tips++1. **Choose Premium voices first** - They have the highest quality+2. **Use Enhanced when Premium unavailable** - Still excellent quality+3. **Avoid voices without labels** - These are legacy robotic voices+4. **Customize speech rates** - Edit `voices.json` to adjust speeds+5. **Test voices before committing** - Use the curl commands above+6. **Different accents for clarity** - Mix of US, UK, and Indian helps distinguish speakers## 🆘 Support-For issues or questions:-1. Check the troubleshooting section above-2. Review logs at `~/Library/Logs/pai-voice-server.log`-3. Ensure your ElevenLabs API key is valid-4. Try the fallback mode (without API key) to isolate issues\ No newline at end of file+For issues:+1. Check [Troubleshooting](#-troubleshooting) section+2. Verify voices are downloaded (System Settings → Voice (Live Speech))+3. Test voice directly: `say -v "Jamie (Premium)" "test"`+4. Check server is running: `curl http://localhost:8888/health`+5. See [voice-system.md](../documentation/voice-system.md) for detailed documentation++---++**Zero cost. Complete privacy. Natural voices. That's the PAI way.** 🎙️diff --git a/PAI_DIRECTORY/voice-server/server.ts b/PAI_DIRECTORY/voice-server/server.tsindex dd6c177d..4b267e72 100644--- a/PAI_DIRECTORY/voice-server/server.ts+++ b/PAI_DIRECTORY/voice-server/server.ts@@ -24,8 +24,8 @@ if (existsSync(envPath)) {const PORT = parseInt(process.env.PORT || "8888");// macOS Voice configuration-// When null, uses system default (highest quality neural voice)-const DEFAULT_VOICE = null;+// Jamie (Premium) is Kai's voice - UK Male, professional and conversational+const DEFAULT_VOICE = "Jamie (Premium)";// Sanitize input for shell commandsfunction sanitizeForShell(input: string): string {diff --git a/PAI_DIRECTORY/voice-server/voices.json b/PAI_DIRECTORY/voice-server/voices.jsonnew file mode 100644index 00000000..129a9601--- /dev/null+++ b/PAI_DIRECTORY/voice-server/voices.json@@ -0,0 +1,55 @@+{+ "$schema": "./voices-schema.json",+ "default_rate": 175,+ "voices": {+ "kai": {+ "voice_name": "Jamie (Premium)",+ "rate_multiplier": 1.3,+ "rate_wpm": 228,+ "description": "UK Male - Professional, conversational",+ "type": "Premium"+ },+ "researcher": {+ "voice_name": "Ava (Premium)",+ "rate_multiplier": 1.35,+ "rate_wpm": 236,+ "description": "US Female - Analytical, highest quality",+ "type": "Premium"+ },+ "engineer": {+ "voice_name": "Tom (Enhanced)",+ "rate_multiplier": 1.35,+ "rate_wpm": 236,+ "description": "US Male - Steady, professional",+ "type": "Enhanced"+ },+ "architect": {+ "voice_name": "Serena (Premium)",+ "rate_multiplier": 1.35,+ "rate_wpm": 236,+ "description": "UK Female - Strategic, sophisticated",+ "type": "Premium"+ },+ "designer": {+ "voice_name": "Isha (Premium)",+ "rate_multiplier": 1.35,+ "rate_wpm": 236,+ "description": "Indian Female - Creative, distinct",+ "type": "Premium"+ },+ "pentester": {+ "voice_name": "Oliver (Enhanced)",+ "rate_multiplier": 1.35,+ "rate_wpm": 236,+ "description": "UK Male - Technical, sharp",+ "type": "Enhanced"+ },+ "writer": {+ "voice_name": "Samantha (Enhanced)",+ "rate_multiplier": 1.35,+ "rate_wpm": 236,+ "description": "US Female - Articulate, warm",+ "type": "Enhanced"+ }+ }+}diff --git a/README.md b/README.mdindex 69b3fb09..dd7ead6d 100644--- a/README.md+++ b/README.md@@ -517,10 +517,9 @@ source ~/.zshrc # or source ~/.bashrc# Copy environment template to PAI_DIRECTORYcp ${PAI_DIR}/env-example ${PAI_DIR}/.env-# Add your API keys (optional but recommended)+# Add your API keys (optional)vim ${PAI_DIR}/.env-# Add: ELEVENLABS_API_KEY="your_key_here"-# Add: OPENAI_API_KEY="your_key_here"+# Add: OPENAI_API_KEY="your_key_here" (if using GPT integration)```#### **Step 5: Launch PAI**@@ -529,8 +528,11 @@ vim ${PAI_DIR}/.env# Navigate to PAI directorycd ${PAI_DIR}-# Optional: Start voice server for audio notifications-cd voice-server && ./install.sh && ./start.sh+# Optional: Set up voice notifications (macOS only)+# Download Premium/Enhanced voices from System Settings → Voice (Live Speech)+# Then start the voice server:+cd voice-server && bun server.ts &+# See documentation/VOICE-SETUP-GUIDE.md for detailed setup instructions# Open Claude Code and start using PAI!# Your personal AI infrastructure is ready 🚀@@ -544,9 +546,8 @@ PAI_DIR="/path/to/PAI/PAI_DIRECTORY" # PAI's PAI_DIRECTORY (system agnostic)PAI_HOME="$HOME" # Your home directory# Optional API Keys-ELEVENLABS_API_KEY="your_key" # Voice synthesis-OPENAI_API_KEY="your_key" # GPT integration-PORT="8888" # Voice server port+OPENAI_API_KEY="your_key" # GPT integration (optional)+PORT="8888" # Voice server port (default: 8888)# Digital Assistant CustomizationDA="YourAssistantName" # Your AI assistant's name (default: "Assistant")