Files
tts-server/examples/chime.mjs
mikael-lovqvists-claude-agent f6ff8c72e8 Convert chatterbox-server.py to HTTP server, add Node.js examples
Replace stdin/stdout JSON line protocol with a stdlib HTTP server
(ThreadingHTTPServer). Three endpoints: POST /speak, /chime, /preload.
All return {"status": "ok"} after audio is queued for playback.
TTS generation is serialized via a threading.Lock; concurrent chime/preload
requests are handled without waiting for generation.

Add examples/speak.mjs, chime.mjs, voice-clone.mjs using Node.js built-in
fetch (no libraries required, Node 18+).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 07:28:18 +00:00

23 lines
548 B
JavaScript

// Play a chime WAV file via the Chatterbox TTS server.
// Usage: node chime.mjs /path/to/chime.wav
const PORT = process.env.TTS_PORT ?? '11500'
const path = process.argv[2]
if (!path) {
console.error('usage: node chime.mjs /path/to/chime.wav')
process.exit(1)
}
const res = await fetch(`http://localhost:${PORT}/chime`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ path }),
})
const data = await res.json()
if (data.status !== 'ok') {
console.error('error:', data.message)
process.exit(1)
}