forked from efforting.tech/tts-server
Single port (TTS_PORT) handles both the WS upgrade handshake and connections. Adds job queue, generation worker, playback events (queued/started/finished/aborted/error), and abort_current/abort_all commands. Fixes BrokenPipeError when pacat is killed mid-write. Updates all examples to use WebSocket; adds abort-demo.mjs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
542 B
JavaScript
25 lines
542 B
JavaScript
// Gracefully terminate the Chatterbox TTS server.
|
|
// Usage: node terminate.mjs
|
|
|
|
const PORT = process.env.TTS_PORT ?? '11500'
|
|
|
|
const ws = new WebSocket(`ws://localhost:${PORT}`)
|
|
|
|
ws.addEventListener('open', () => {
|
|
ws.send(JSON.stringify({ type: 'terminate' }))
|
|
})
|
|
|
|
ws.addEventListener('message', ({ data }) => {
|
|
const msg = JSON.parse(data)
|
|
if (msg.status !== 'ok') {
|
|
console.error('error:', msg.message)
|
|
process.exit(1)
|
|
}
|
|
ws.close()
|
|
})
|
|
|
|
ws.addEventListener('error', (e) => {
|
|
console.error('error:', e.message)
|
|
process.exit(1)
|
|
})
|