import fs from 'node:fs'; import path from 'node:path'; import os from 'node:os'; function flag(value, fallback = true) { if (value === undefined || value === null) return fallback; if (typeof value === 'string') return !['false', '0', 'off', 'no'].includes(value.trim().toLowerCase()); return value !== false; } export function voiceSettings(source = null) { let config = source; if (!config) { config = {}; try { config = JSON.parse(fs.readFileSync(path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'jarvis/config.json'), 'utf8')); } catch {} } const phrase = config.wakePhrase || config.wake_phrase || 'hey jarvis'; const aliases = Array.isArray(config.aliases) ? config.aliases : ['jarvis', 'okay jarvis']; return { command: process.env.JARVIS_WAKE_COMMAND || config.wakeCommand || config.wake_command || '', phrases: [phrase, ...aliases].map((item) => String(item || '').trim()).filter(Boolean), ttsEnabled: flag(config.ttsEnabled ?? config.tts_enabled, true), modelProfile: config.modelProfile || config.model_profile || 'laptop-16gb', }; }