STT (Silero VAD + Whisper via sherpa-onnx), Chatterbox TTS HTTP server, query completeness classifier (Ollama), multi-voice demo scripts, and planning docs. Kept as reference; clean rewrite planned in separate repos. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
66 lines
1.7 KiB
JavaScript
66 lines
1.7 KiB
JavaScript
/**
|
|
* Voice buddy — reads voice queries from stdin (JSON lines) and dispatches
|
|
* them to a Claude Code instance via claude-remote.
|
|
*
|
|
* Usage:
|
|
* node query-demo.mjs | node voice-buddy.mjs --window-id 0x1234abc --claude-remote /workspace/claude-remote/claude-remote.mjs
|
|
*
|
|
* Options:
|
|
* --window-id <id> X11 window ID of Claude Code (decimal or 0x hex)
|
|
* --claude-remote <path> Path to claude-remote.mjs
|
|
*/
|
|
|
|
import * as readline from 'node:readline'
|
|
import { execFileSync } from 'node:child_process'
|
|
|
|
const args = process.argv.slice(2)
|
|
|
|
function get_arg(name) {
|
|
const i = args.indexOf(name)
|
|
if (i === -1 || i + 1 >= args.length) {
|
|
process.stderr.write(`Missing argument: ${name}\n`)
|
|
process.exit(1)
|
|
}
|
|
return args[i + 1]
|
|
}
|
|
|
|
const window_id = get_arg('--window-id')
|
|
const claude_remote = get_arg('--claude-remote')
|
|
|
|
function make_prompt(query) {
|
|
return [
|
|
'[voice-buddy] You have received a voice query.',
|
|
'',
|
|
'Respond via the `speak` shell command. Keep your response brief and spoken-word natural — this is a voice interface.',
|
|
'',
|
|
'--- Query ---',
|
|
query,
|
|
'--- End of query ---',
|
|
].join('\n')
|
|
}
|
|
|
|
function dispatch(query) {
|
|
const prompt = make_prompt(query)
|
|
process.stderr.write(`[voice-buddy] dispatching: ${JSON.stringify(query)}\n`)
|
|
execFileSync('node', [claude_remote, '--window-id', window_id], {
|
|
input: prompt,
|
|
encoding: 'utf8',
|
|
stdio: ['pipe', 'inherit', 'inherit'],
|
|
})
|
|
}
|
|
|
|
const rl = readline.createInterface({ input: process.stdin })
|
|
|
|
for await (const line of rl) {
|
|
const trimmed = line.trim()
|
|
if (!trimmed) {
|
|
continue
|
|
}
|
|
try {
|
|
const query = JSON.parse(trimmed)
|
|
dispatch(query)
|
|
} catch {
|
|
process.stderr.write(`[voice-buddy] bad JSON line: ${trimmed}\n`)
|
|
}
|
|
}
|