mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
Feat/tts streaming (#994)
* wip * add TtsStreamingBuffer class to abstract handling of streaming tokens * wip * add throttling support * support background ttsStream (#995) * wip * add TtsStreamingBuffer class to abstract handling of streaming tokens * wip * support background ttsStream * wip --------- Co-authored-by: Dave Horton <daveh@beachdognet.com> * wip * dont send if we have nothing to send * initial testing with cartesia * wip --------- Co-authored-by: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com>
This commit is contained in:
@@ -12,6 +12,20 @@ const {
|
||||
JAMBONES_WS_MAX_PAYLOAD,
|
||||
HTTP_USER_AGENT_HEADER
|
||||
} = require('../config');
|
||||
const MTYPE_WANTS_ACK = [
|
||||
'call:status',
|
||||
'verb:status',
|
||||
'jambonz:error',
|
||||
'llm:event',
|
||||
'llm:tool-call',
|
||||
'tts:streaming-event',
|
||||
'tts:tokens-result',
|
||||
];
|
||||
const MTYPE_NO_DATA = [
|
||||
'llm:tool-output',
|
||||
'tts:flush',
|
||||
'tts:clear'
|
||||
];
|
||||
|
||||
class WsRequestor extends BaseRequestor {
|
||||
constructor(logger, account_sid, hook, secret) {
|
||||
@@ -44,7 +58,7 @@ class WsRequestor extends BaseRequestor {
|
||||
async request(type, hook, params, httpHeaders = {}) {
|
||||
assert(HookMsgTypes.includes(type));
|
||||
const url = hook.url || hook;
|
||||
const wantsAck = !['call:status', 'verb:status', 'jambonz:error', 'llm:event', 'llm:tool-call'].includes(type);
|
||||
const wantsAck = !MTYPE_WANTS_ACK.includes(type);
|
||||
|
||||
if (this.maliciousClient) {
|
||||
this.logger.info({url: this.url}, 'WsRequestor:request - discarding msg to malicious client');
|
||||
@@ -408,7 +422,7 @@ class WsRequestor extends BaseRequestor {
|
||||
|
||||
case 'command':
|
||||
assert.ok(command, 'command property not supplied');
|
||||
assert.ok(data || command === 'llm:tool-output', 'data property not supplied');
|
||||
assert.ok(data || MTYPE_NO_DATA.includes(command), 'data property not supplied');
|
||||
this._recvCommand(msgid, command, call_sid, queueCommand, tool_call_id, data);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user