Compare commits
2 Commits
26837bec6a
...
e15ba903c1
| Author | SHA1 | Date | |
|---|---|---|---|
| e15ba903c1 | |||
| 6357ff6a58 |
@@ -6,6 +6,7 @@ Endpoints:
|
|||||||
POST /speak {"text": "...", "temperature": 0.8, "top_p": 0.95, "audio_prompt": "/path.wav"}
|
POST /speak {"text": "...", "temperature": 0.8, "top_p": 0.95, "audio_prompt": "/path.wav"}
|
||||||
POST /chime {"path": "/path/to/file.wav"}
|
POST /chime {"path": "/path/to/file.wav"}
|
||||||
POST /preload {"path": "/path/to/file.wav"}
|
POST /preload {"path": "/path/to/file.wav"}
|
||||||
|
POST /command {"command": "terminate"}
|
||||||
|
|
||||||
All endpoints return {"status": "ok"} or {"status": "error", "message": "..."}.
|
All endpoints return {"status": "ok"} or {"status": "error", "message": "..."}.
|
||||||
Responses are sent after audio is queued for playback (not after playback finishes).
|
Responses are sent after audio is queued for playback (not after playback finishes).
|
||||||
@@ -237,6 +238,14 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.send_json({'status': 'error', 'message': str(e)}, 500)
|
self.send_json({'status': 'error', 'message': str(e)}, 500)
|
||||||
|
|
||||||
|
elif self.path == '/command':
|
||||||
|
command = req.get('command', '')
|
||||||
|
if command == 'terminate':
|
||||||
|
self.send_json({'status': 'ok'})
|
||||||
|
threading.Thread(target=server.shutdown, daemon=True).start()
|
||||||
|
else:
|
||||||
|
self.send_json({'status': 'error', 'message': f'unknown command: {command}'}, 400)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.send_json({'status': 'error', 'message': 'not found'}, 404)
|
self.send_json({'status': 'error', 'message': 'not found'}, 404)
|
||||||
|
|
||||||
|
|||||||
16
examples/terminate.mjs
Normal file
16
examples/terminate.mjs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// Gracefully terminate the Chatterbox TTS server.
|
||||||
|
// Usage: node terminate.mjs
|
||||||
|
|
||||||
|
const PORT = process.env.TTS_PORT ?? '11500'
|
||||||
|
|
||||||
|
const res = await fetch(`http://localhost:${PORT}/command`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ command: 'terminate' }),
|
||||||
|
})
|
||||||
|
|
||||||
|
const data = await res.json()
|
||||||
|
if (data.status !== 'ok') {
|
||||||
|
console.error('error:', data.message)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user