⛰️ LifeOS — The AI-powered Life Operating System that helps you hill climb to wherever you're going.
feat(kai-voice-system): Add Google Cloud TTS provider (#285)
Eli Fayerman944914fd4c88
diff --git a/Packs/kai-voice-system/INSTALL.md b/Packs/kai-voice-system/INSTALL.mdindex 8165ae08..69b5c496 100644--- a/Packs/kai-voice-system/INSTALL.md+++ b/Packs/kai-voice-system/INSTALL.md@@ -3,19 +3,19 @@## Prerequisites- **Bun runtime**: `curl -fsSL https://bun.sh/install | bash`-- **macOS REQUIRED**: Uses `afplay` for audio playback (see platform note below)-- **ElevenLabs account**: Sign up at [elevenlabs.io](https://elevenlabs.io)+- **macOS or Linux**: Cross-platform audio support included+- **TTS API account** (choose one):+ - **Google Cloud** (recommended): 4M free chars/month - [console.cloud.google.com](https://console.cloud.google.com)+ - **ElevenLabs**: ~10K free chars/month - [elevenlabs.io](https://elevenlabs.io)- **Required PAI Packs** (install these first):- `kai-hook-system` - Foundation hook infrastructure- `kai-core-install` - Skills, identity, and response format----## 🚨 CRITICAL: Platform Compatibility Check+## Platform Compatibility Check-> **FOR AI AGENTS:** You MUST run this check FIRST. If the user is on Linux or Windows, STOP and inform them before proceeding.--### Step 0.0: Operating System Check (MANDATORY)+### Step 0.0: Operating System Check```bashOS_TYPE="$(uname -s)"@@ -23,31 +23,33 @@ echo "Detected OS: $OS_TYPE"if [ "$OS_TYPE" = "Darwin" ]; thenecho "✓ macOS detected - Voice system is fully supported"+ echo " Audio: afplay (built-in)"elif [ "$OS_TYPE" = "Linux" ]; then+ echo "✓ Linux detected - Voice system is fully supported"echo ""- echo "⚠️ WARNING: Linux detected"- echo ""- echo "The Kai Voice System currently requires macOS because:"- echo " 1. Uses 'afplay' for audio playback (macOS built-in)"- echo " 2. Uses LaunchAgent for auto-start (macOS only)"- echo ""- echo "Linux alternatives (requires code modification):"- echo " - Replace 'afplay' with 'aplay', 'paplay', or 'mpv'"- echo " - Replace LaunchAgent with systemd service"- echo ""- echo "Do you want to proceed anyway? (You'll need to modify the code)"- echo "If proceeding, you MUST manually replace audio playback commands."+ echo "Checking audio players..."+ if command -v mpg123 &> /dev/null; then+ echo " ✓ mpg123 found (preferred)"+ elif command -v mpv &> /dev/null; then+ echo " ✓ mpv found"+ elif command -v paplay &> /dev/null; then+ echo " ✓ paplay found"+ else+ echo " ⚠️ No audio player found. Install one:"+ echo " sudo apt install mpg123 # Recommended"+ echo " sudo apt install mpv"+ fielseecho ""echo "❌ UNSUPPORTED: $OS_TYPE detected"- echo "The Kai Voice System only supports macOS (and Linux with modifications)."+ echo "The Kai Voice System supports macOS and Linux only."echo "Windows is not currently supported."fi```**AI Agent Instructions:**- If OS is macOS → Proceed with installation-- If OS is Linux → Warn user, get explicit confirmation, note they must modify `afplay` calls+- If OS is Linux → Ensure audio player is installed (mpg123 recommended), then proceed- If OS is Windows → STOP, do not proceed, inform user it's unsupported---@@ -104,12 +106,20 @@ elseecho "❌ kai-core-install NOT installed - REQUIRED!"fi-# Check for ElevenLabs API key+# Check for TTS API key (either Google or ElevenLabs)PAI_ENV="${PAI_DIR:-$HOME/.config/pai}/.env"-if [ -f "$PAI_ENV" ] && grep -q "ELEVENLABS_API_KEY" "$PAI_ENV"; then- echo "✓ ELEVENLABS_API_KEY found"+if [ -f "$PAI_ENV" ]; then+ if grep -q "GOOGLE_API_KEY" "$PAI_ENV"; then+ echo "✓ GOOGLE_API_KEY found (Google TTS available)"+ fi+ if grep -q "ELEVENLABS_API_KEY" "$PAI_ENV"; then+ echo "✓ ELEVENLABS_API_KEY found (ElevenLabs available)"+ fi+ if ! grep -q "GOOGLE_API_KEY\|ELEVENLABS_API_KEY" "$PAI_ENV"; then+ echo "⚠️ No TTS API key found - add GOOGLE_API_KEY or ELEVENLABS_API_KEY to $PAI_ENV"+ fielse- echo "⚠️ ELEVENLABS_API_KEY not found - add to $PAI_ENV"+ echo "⚠️ No .env file found at $PAI_ENV"fi```@@ -183,14 +193,54 @@ Copy `src/voice/server.ts` to `$PAI_DIR/voice-server/server.ts`----## Step 6: Set Up ElevenLabs Account+## Step 6: Set Up TTS Provider++Choose one of the following providers:++### Option A: Google Cloud TTS (Recommended)++**Why Google?** 4 million free characters per month vs ~10K for ElevenLabs. Effectively unlimited for PAI notifications.++1. **Create a Google Cloud project** at [console.cloud.google.com](https://console.cloud.google.com)+2. **Enable Cloud Text-to-Speech API**:+ - Go to APIs & Services → Library+ - Search for "Cloud Text-to-Speech API"+ - Click Enable+3. **Create API key**:+ - Go to APIs & Services → Credentials+ - Create Credentials → API Key+ - (Optional) Restrict key to Cloud Text-to-Speech API+4. **Add to $PAI_DIR/.env**:++```bash+TTS_PROVIDER=google+GOOGLE_API_KEY=your-google-api-key+GOOGLE_TTS_VOICE=en-US-Neural2-J # Optional, this is the default+```++5. **Test your API key**:++```bash+curl -X POST "https://texttospeech.googleapis.com/v1/text:synthesize?key=YOUR_API_KEY" \+ -H "Content-Type: application/json" \+ -d '{"input":{"text":"Hello, this is Google Cloud TTS."},"voice":{"languageCode":"en-US","name":"en-US-Neural2-J"},"audioConfig":{"audioEncoding":"MP3"}}' \+ | jq -r '.audioContent' | base64 -d > test.mp3++# Play (macOS: afplay, Linux: mpg123)+mpg123 test.mp3 || afplay test.mp3+rm test.mp3+```++### Option B: ElevenLabs1. **Sign up** at [elevenlabs.io](https://elevenlabs.io)-2. **Get your API key** from Profile + API key+2. **Get your API key** from Profile → API key3. **Add to $PAI_DIR/.env**:```bash-ELEVENLABS_API_KEY="your-api-key"+TTS_PROVIDER=elevenlabs+ELEVENLABS_API_KEY=your-api-key+ELEVENLABS_VOICE_ID=your-voice-id```4. **Test your API key**:@@ -202,7 +252,7 @@ curl -X POST "https://api.elevenlabs.io/v1/text-to-speech/s3TPKV1kjDlVtZbl4Ksh"-d '{"text": "Hello, this is a test.", "model_id": "eleven_turbo_v2_5"}' \--output test.mp3-afplay test.mp3 # Should hear "Hello, this is a test"+mpg123 test.mp3 || afplay test.mp3 # Should hear "Hello, this is a test"rm test.mp3```@@ -303,15 +353,38 @@ Run the verification checklist in VERIFY.md to confirm everything works.### No Voice Output1. Check voice server is running: `curl http://localhost:8888/health`-2. Verify ElevenLabs API key is set in `$PAI_DIR/.env`-3. Check logs: `tail -f ~/Library/Logs/pai-voice-server.log`+2. Verify TTS API key is set in `$PAI_DIR/.env`+3. Check which provider is active: response shows `provider: google` or `provider: elevenlabs`+4. Check logs: `tail -f $PAI_DIR/voice-server/voice-server.log`++### Google TTS Errors++| Error | Solution |+|-------|----------|+| `SERVICE_DISABLED` | Enable Cloud Text-to-Speech API in Google Cloud Console |+| `API_KEY_SERVICE_BLOCKED` | Add Cloud Text-to-Speech API to allowed APIs for your key |+| `PERMISSION_DENIED` | Check API key is valid and has correct permissions |++### ElevenLabs Errors++| Error | Solution |+|-------|----------|+| `invalid_uid` | Remove quotes from API key in .env: `ELEVENLABS_API_KEY=abc123` not `"abc123"` |+| `quota_exceeded` | Free tier exhausted. Consider switching to Google TTS |+| `missing_permissions` | Enable TTS permission in ElevenLabs dashboard |### Wrong Voice1. Verify voice ID in `config/voice-personalities.json`2. Check agent type is being detected correctly in hooks-### Audio Playback Issues+### Audio Playback Issues (Linux)++1. Install an audio player: `sudo apt install mpg123`+2. Check it works: `echo "test" | mpg123 -`+3. Server auto-detects: mpg123 → mpv → paplay++### Audio Playback Issues (macOS)1. Ensure `afplay` is available (macOS built-in)2. Check system volumediff --git a/Packs/kai-voice-system/README.md b/Packs/kai-voice-system/README.mdindex 25528dce..68693725 100644--- a/Packs/kai-voice-system/README.md+++ b/Packs/kai-voice-system/README.md@@ -1,16 +1,16 @@---name: Kai Voice System-pack-id: danielmiessler-kai-voice-system-core-v1.2.0-version: 1.2.0+pack-id: danielmiessler-kai-voice-system-core-v1.3.0+version: 1.3.0author: danielmiessler-description: Voice notification system with ElevenLabs TTS, prosody enhancement for natural speech, and agent personality-driven voice delivery+description: Voice notification system with multi-provider TTS (Google Cloud or ElevenLabs), prosody enhancement for natural speech, and agent personality-driven voice deliverytype: featurepurpose-type: [notifications, accessibility, automation]-platform: macos (linux with modifications)+platform: macos, linuxdependencies:- kai-hook-system (required) - Hooks trigger voice notifications- kai-core-install (required) - Skills, identity, and response format drive voice output-keywords: [voice, tts, elevenlabs, notifications, prosody, speech, agents, personalities, accessibility]+keywords: [voice, tts, elevenlabs, google-cloud-tts, notifications, prosody, speech, agents, personalities, accessibility]---<p align="center">@@ -26,28 +26,74 @@ keywords: [voice, tts, elevenlabs, notifications, prosody, speech, agents, perso| Platform | Status | Notes ||----------|--------|-------|| **macOS** | ✅ Fully Supported | Uses `afplay` (built-in) for audio playback |-| **Linux** | ⚠️ Requires Modification | Must replace `afplay` with `aplay`, `paplay`, or `mpv` |+| **Linux** | ✅ Fully Supported | Auto-detects `mpg123`, `mpv`, or `paplay` for audio || **Windows** | ❌ Not Supported | No current implementation |-**Before installing:** The installation guide will check your OS and warn you if modifications are needed.+**Audio player priority (Linux):** mpg123 → mpv → paplay (install one: `sudo apt install mpg123`)---## What This Pack Provides-- **Spoken Notifications**: Hear task completions via ElevenLabs text-to-speech+- **Spoken Notifications**: Hear task completions via text-to-speech+- **Multi-Provider TTS**: Choose between Google Cloud TTS or ElevenLabs- **Prosody Enhancement**: Natural speech patterns with emotional markers- **Agent Personalities**: Different voices for different agent types- **Intelligent Cleaning**: Strips code blocks and artifacts for clean speech- **Graceful Degradation**: Works silently when voice server is offline+## TTS Provider Options++Choose your text-to-speech provider based on your needs:++| Provider | Free Tier | Quality | Setup |+|----------|-----------|---------|-------|+| **Google Cloud TTS** | 4M chars/month | High (Neural2/WaveNet) | Google API key |+| **ElevenLabs** | ~10K chars/month | Premium | ElevenLabs API key |++**Recommendation:** Google Cloud TTS offers **400x more free characters** — effectively unlimited for typical PAI notification usage.++### Configuration++Set in your `.env` file:++```bash+# Choose provider: "google" or "elevenlabs" (default: elevenlabs)+TTS_PROVIDER=google++# Google Cloud TTS (if using google)+GOOGLE_API_KEY=your_google_api_key+GOOGLE_TTS_VOICE=en-US-Neural2-J # Optional, has sensible default++# ElevenLabs (if using elevenlabs)+ELEVENLABS_API_KEY=your_api_key+ELEVENLABS_VOICE_ID=your_voice_id+```++### Google Cloud TTS Voices++| Voice | Type | Description |+|-------|------|-------------|+| `en-US-Neural2-J` | Neural2 (default) | Natural male voice |+| `en-US-Neural2-F` | Neural2 | Natural female voice |+| `en-US-Wavenet-D` | WaveNet | Premium male voice |+| `en-US-Standard-A` | Standard | Basic voice (more free chars) |++See [Google Cloud TTS voices](https://cloud.google.com/text-to-speech/docs/voices) for full list.+## Architecture Overview```┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐-│ Stop Hook │ ───► │ Voice Server │ ───► │ ElevenLabs │-│ (extracts msg) │ │ (localhost:8888)│ │ (TTS API) │-└─────────────────┘ └──────────────────┘ └─────────────────┘+│ Stop Hook │ ───► │ Voice Server │ ───► │ TTS Provider │+│ (extracts msg) │ │ (localhost:8888)│ │ │+└─────────────────┘ └──────────────────┘ │ ┌─────────────┐ │+ │ │ Google TTS │ │+ │ └─────────────┘ │+ │ ┌─────────────┐ │+ │ │ ElevenLabs │ │+ │ └─────────────┘ │+ └─────────────────┘```## The 5-Layer Prosody Enhancement Pipeline@@ -79,7 +125,8 @@ keywords: [voice, tts, elevenlabs, notifications, prosody, speech, agents, perso**Summary:**- **Files created:** 7- **Hooks registered:** 2 (Stop, SubagentStop)-- **Dependencies:** kai-hook-system (required), kai-core-install (required), ElevenLabs API key+- **Dependencies:** kai-hook-system (required), kai-core-install (required)+- **TTS API key:** Google Cloud API key OR ElevenLabs API key (choose one)## Agent Voice Mappingdiff --git a/Packs/kai-voice-system/src/voice/server.ts b/Packs/kai-voice-system/src/voice/server.tsindex dc1959b9..4336732c 100644--- a/Packs/kai-voice-system/src/voice/server.ts+++ b/Packs/kai-voice-system/src/voice/server.ts@@ -1,6 +1,8 @@#!/usr/bin/env bun// $PAI_DIR/voice-server/server.ts-// Voice notification server using ElevenLabs TTS+// Voice notification server with multi-provider TTS support+// Supports: Google Cloud TTS, ElevenLabs+// Platforms: macOS, Linuximport { serve } from "bun";import { spawn } from "child_process";@@ -22,15 +24,38 @@ if (existsSync(envPath)) {}const PORT = parseInt(process.env.PAI_VOICE_PORT || "8888");++// =============================================================================+// TTS Provider Configuration+// =============================================================================+// Options: "google" | "elevenlabs" (default: elevenlabs for backward compatibility)+const TTS_PROVIDER = (process.env.TTS_PROVIDER || 'elevenlabs').toLowerCase();++// ElevenLabs Configurationconst ELEVENLABS_API_KEY = process.env.ELEVENLABS_API_KEY;+const DEFAULT_ELEVENLABS_VOICE = process.env.ELEVENLABS_VOICE_ID || "s3TPKV1kjDlVtZbl4Ksh";-if (!ELEVENLABS_API_KEY) {+// Google Cloud TTS Configuration+// Free tier: 4M chars/month (Standard), 1M chars/month (WaveNet/Neural2)+// This is ~800x more than ElevenLabs' free tier+const GOOGLE_API_KEY = process.env.GOOGLE_API_KEY;+const GOOGLE_TTS_VOICE = process.env.GOOGLE_TTS_VOICE || "en-US-Neural2-J";++// Validate provider configuration+if (TTS_PROVIDER === 'elevenlabs' && !ELEVENLABS_API_KEY) {console.error(`⚠️ ELEVENLABS_API_KEY not found in ${envPath}`);console.error('Add: ELEVENLABS_API_KEY=your_key_here to $PAI_DIR/.env');+ console.error('Or switch to Google TTS: TTS_PROVIDER=google');}-// Default voice ID (customize to your preference)-const DEFAULT_VOICE_ID = process.env.ELEVENLABS_VOICE_ID || "s3TPKV1kjDlVtZbl4Ksh";+if (TTS_PROVIDER === 'google' && !GOOGLE_API_KEY) {+ console.error(`⚠️ GOOGLE_API_KEY not found in ${envPath}`);+ console.error('Add: GOOGLE_API_KEY=your_key_here to $PAI_DIR/.env');+ console.error('Note: Enable Cloud Text-to-Speech API in Google Cloud Console');+}++// Default voice based on provider+const DEFAULT_VOICE_ID = TTS_PROVIDER === 'google' ? GOOGLE_TTS_VOICE : DEFAULT_ELEVENLABS_VOICE;// Voice configuration typesinterface VoiceConfig {@@ -137,8 +162,12 @@ function validateInput(input: any): { valid: boolean; error?: string; sanitized?return { valid: true, sanitized };}-// Generate speech using ElevenLabs API-async function generateSpeech(+// =============================================================================+// TTS Providers+// =============================================================================++// ElevenLabs TTS Generation+async function generateSpeechElevenLabs(text: string,voiceId: string,voiceSettings?: { stability: number; similarity_boost: number }@@ -172,6 +201,75 @@ async function generateSpeech(return await response.arrayBuffer();}+// Google Cloud TTS Generation+// Free tier: 4M chars/month (Standard), 1M chars/month (WaveNet/Neural2)+async function generateSpeechGoogle(+ text: string,+ voice?: string+): Promise<ArrayBuffer> {+ if (!GOOGLE_API_KEY) {+ throw new Error('Google API key not configured. Add GOOGLE_API_KEY to your .env file.');+ }++ const voiceName = voice || GOOGLE_TTS_VOICE;+ // Extract language code from voice name (e.g., "en-US" from "en-US-Neural2-J")+ const languageCode = voiceName.split('-').slice(0, 2).join('-');++ const url = `https://texttospeech.googleapis.com/v1/text:synthesize?key=${GOOGLE_API_KEY}`;++ const response = await fetch(url, {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json',+ },+ body: JSON.stringify({+ input: { text },+ voice: {+ languageCode,+ name: voiceName,+ },+ audioConfig: {+ audioEncoding: 'MP3',+ speakingRate: 1.0,+ pitch: 0,+ },+ }),+ });++ if (!response.ok) {+ const errorText = await response.text();+ throw new Error(`Google TTS API error: ${response.status} - ${errorText}`);+ }++ const data = await response.json();++ // Google returns base64-encoded audio in the 'audioContent' field+ if (!data.audioContent) {+ throw new Error('Google TTS: No audio content in response');+ }++ // Decode base64 to ArrayBuffer+ const binaryString = atob(data.audioContent);+ const bytes = new Uint8Array(binaryString.length);+ for (let i = 0; i < binaryString.length; i++) {+ bytes[i] = binaryString.charCodeAt(i);+ }+ return bytes.buffer;+}++// Unified speech generation - routes to the configured provider+async function generateSpeech(+ text: string,+ voiceId: string,+ voiceSettings?: { stability: number; similarity_boost: number }+): Promise<ArrayBuffer> {+ if (TTS_PROVIDER === 'google') {+ return generateSpeechGoogle(text, voiceId);+ } else {+ return generateSpeechElevenLabs(text, voiceId, voiceSettings);+ }+}+// Get volume setting from config (defaults to 0.8 = 80%)function getVolumeSetting(): number {if (voicesConfig && typeof voicesConfig.default_volume === 'number') {@@ -181,37 +279,67 @@ function getVolumeSetting(): number {return 0.8;}-// Play audio using afplay (macOS)+// =============================================================================+// Cross-Platform Audio Playback+// =============================================================================++// Play audio - supports macOS (afplay) and Linux (mpg123, mpv)async function playAudio(audioBuffer: ArrayBuffer): Promise<void> {const tempFile = `/tmp/voice-${Date.now()}.mp3`;await Bun.write(tempFile, audioBuffer);const volume = getVolumeSetting();return new Promise((resolve, reject) => {- const proc = spawn('/usr/bin/afplay', ['-v', volume.toString(), tempFile]);+ let player: string;+ let args: string[];++ if (process.platform === 'darwin') {+ // macOS: use afplay+ player = '/usr/bin/afplay';+ args = ['-v', volume.toString(), tempFile];+ } else {+ // Linux: try mpg123 first, then mpv+ if (existsSync('/usr/bin/mpg123')) {+ player = '/usr/bin/mpg123';+ args = ['-q', tempFile];+ } else if (existsSync('/usr/bin/mpv')) {+ player = '/usr/bin/mpv';+ args = ['--no-terminal', '--volume=' + (volume * 100), tempFile];+ } else if (existsSync('/snap/bin/mpv')) {+ player = '/snap/bin/mpv';+ args = ['--no-terminal', '--volume=' + (volume * 100), tempFile];+ } else {+ console.warn('⚠️ No audio player found. Install mpg123 or mpv for audio playback.');+ spawn('/bin/rm', [tempFile]);+ resolve();+ return;+ }+ }++ const proc = spawn(player, args);proc.on('error', (error) => {console.error('Error playing audio:', error);+ spawn('/bin/rm', [tempFile]);reject(error);});proc.on('exit', (code) => {spawn('/bin/rm', [tempFile]); // Clean up temp file- if (code === 0) {+ if (code === 0 || code === null) {resolve();} else {- reject(new Error(`afplay exited with code ${code}`));+ reject(new Error(`${player} exited with code ${code}`));}});});}-// Escape for AppleScript notifications-function escapeForAppleScript(input: string): string {- return input.replace(/\\/g, '\\\\').replace(/"/g, '\\"');-}+// =============================================================================+// Cross-Platform Notifications+// =============================================================================-// Send macOS notification with voice+// Send notification with voiceasync function sendNotification(title: string,message: string,@@ -231,8 +359,9 @@ async function sendNotification(const { cleaned, emotion } = extractEmotionalMarker(safeMessage);safeMessage = cleaned;- // Generate and play voice using ElevenLabs- if (voiceEnabled && ELEVENLABS_API_KEY) {+ // Generate and play voice+ const apiKeyConfigured = TTS_PROVIDER === 'google' ? GOOGLE_API_KEY : ELEVENLABS_API_KEY;+ if (voiceEnabled && apiKeyConfigured) {try {const voice = voiceId || DEFAULT_VOICE_ID;const voiceConfig = getVoiceConfig(voice);@@ -260,12 +389,18 @@ async function sendNotification(}}- // Display macOS notification+ // Display desktop notification (platform-aware)try {- const escapedTitle = escapeForAppleScript(safeTitle);- const escapedMessage = escapeForAppleScript(safeMessage);- const script = `display notification "${escapedMessage}" with title "${escapedTitle}" sound name ""`;- spawn('/usr/bin/osascript', ['-e', script]);+ if (process.platform === 'linux') {+ // Linux: use notify-send+ spawn('/usr/bin/notify-send', [safeTitle, safeMessage]);+ } else if (process.platform === 'darwin') {+ // macOS: use osascript+ const escapedTitle = safeTitle.replace(/\\/g, '\\\\').replace(/"/g, '\\"');+ const escapedMessage = safeMessage.replace(/\\/g, '\\\\').replace(/"/g, '\\"');+ const script = `display notification "${escapedMessage}" with title "${escapedTitle}" sound name ""`;+ spawn('/usr/bin/osascript', ['-e', script]);+ }} catch (error) {console.error("Notification display error:", error);}@@ -346,13 +481,23 @@ const server = serve({// Health check endpointif (url.pathname === "/health") {+ const providerInfo = TTS_PROVIDER === 'google'+ ? { name: 'Google Cloud TTS', configured: !!GOOGLE_API_KEY, voice: GOOGLE_TTS_VOICE }+ : { name: 'ElevenLabs', configured: !!ELEVENLABS_API_KEY, voice: DEFAULT_ELEVENLABS_VOICE };+return new Response(JSON.stringify({status: "healthy",port: PORT,- voice_system: "ElevenLabs",- default_voice_id: DEFAULT_VOICE_ID,- api_key_configured: !!ELEVENLABS_API_KEY+ platform: process.platform,+ tts_provider: providerInfo.name,+ default_voice: providerInfo.voice,+ api_key_configured: providerInfo.configured,+ providers: {+ active: TTS_PROVIDER,+ google: { configured: !!GOOGLE_API_KEY, voice: GOOGLE_TTS_VOICE },+ elevenlabs: { configured: !!ELEVENLABS_API_KEY, voice: DEFAULT_ELEVENLABS_VOICE }+ }}),{ headers: { ...corsHeaders, "Content-Type": "application/json" }, status: 200 });@@ -365,8 +510,17 @@ const server = serve({},});+// Startup logsconsole.log(`🚀 Voice Server running on port ${PORT}`);-console.log(`🎙️ Using ElevenLabs TTS (default voice: ${DEFAULT_VOICE_ID})`);+console.log(`🖥️ Platform: ${process.platform}`);+console.log(`🎙️ TTS Provider: ${TTS_PROVIDER === 'google' ? 'Google Cloud TTS' : 'ElevenLabs'}`);+console.log(`🗣️ Default voice: ${DEFAULT_VOICE_ID}`);console.log(`📡 POST to http://localhost:${PORT}/notify`);console.log(`🔒 Security: CORS restricted to localhost, rate limiting enabled`);-console.log(`🔑 API Key: ${ELEVENLABS_API_KEY ? '✅ Configured' : '❌ Missing'}`);+if (TTS_PROVIDER === 'google') {+ console.log(`🔑 Google API Key: ${GOOGLE_API_KEY ? '✅ Configured' : '❌ Missing'}`);+ console.log(`💰 Free tier: 4M chars/month (Standard), 1M chars/month (Neural2)`);+} else {+ console.log(`🔑 ElevenLabs API Key: ${ELEVENLABS_API_KEY ? '✅ Configured' : '❌ Missing'}`);+}+console.log(`💡 Switch providers: TTS_PROVIDER=google or TTS_PROVIDER=elevenlabs in .env`);