// 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 ws = new WebSocket(`ws://localhost:${PORT}`) ws.addEventListener('open', () => { ws.send(JSON.stringify({ type: 'chime', path })) }) ws.addEventListener('message', ({ data }) => { const msg = JSON.parse(data) if (msg.event === 'finished' || msg.event === 'aborted' || msg.event === 'error') { ws.close() } }) ws.addEventListener('error', (e) => { console.error('error:', e.message) process.exit(1) })