mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
wip
This commit is contained in:
@@ -267,10 +267,8 @@ class TaskSay extends TtsTask {
|
|||||||
const isStreaming = filepath[segment].startsWith('say:{');
|
const isStreaming = filepath[segment].startsWith('say:{');
|
||||||
if (isStreaming) {
|
if (isStreaming) {
|
||||||
const arr = /^say:\{.*\}\s*(.*)$/.exec(filepath[segment]);
|
const arr = /^say:\{.*\}\s*(.*)$/.exec(filepath[segment]);
|
||||||
if (arr) this.logger.debug(`Say:exec sending streaming tts request: ${arr[1].substring(0, 64)}..`);
|
if (arr) this.logger.debug(`Say:exec sending streaming tts request ${arr[1].substring(0, 64)}..`);
|
||||||
}
|
else this.logger.debug(`Say:exec sending ${filepath[segment].substring(0, 64)}`);
|
||||||
else {
|
|
||||||
this.logger.debug(`Say:exec sending ${filepath[segment].substring(0, 64)}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onPlaybackStop = (evt) => {
|
const onPlaybackStop = (evt) => {
|
||||||
@@ -282,10 +280,11 @@ class TaskSay extends TtsTask {
|
|||||||
* If we got a playback id on both the start and stop events, and they don't match,
|
* If we got a playback id on both the start and stop events, and they don't match,
|
||||||
* then we must have received a playback-stop event for an earlier play request.
|
* then we must have received a playback-stop event for an earlier play request.
|
||||||
*/
|
*/
|
||||||
|
const playbackId = this.getPlaybackId(segment);
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
const unmatchedResponse = (!!this.playbackId && !!evt.variable_tts_playback_id) && evt.variable_tts_playback_id !== this.playbackId;
|
const unmatchedResponse = (!!playbackId && !!evt.variable_tts_playback_id) && evt.variable_tts_playback_id !== playbackId;
|
||||||
if (unmatchedResponse) {
|
if (unmatchedResponse) {
|
||||||
this.logger.info({currentPlaybackId: this.playbackId, stopPlaybackId: evt.variable_tts_playback_id},
|
this.logger.info({currentPlaybackId: playbackId, stopPlaybackId: evt.variable_tts_playback_id},
|
||||||
'Say:exec discarding playback-stop for earlier play');
|
'Say:exec discarding playback-stop for earlier play');
|
||||||
ep.once('playback-stop', this._boundOnPlaybackStop);
|
ep.once('playback-stop', this._boundOnPlaybackStop);
|
||||||
|
|
||||||
@@ -359,10 +358,11 @@ class TaskSay extends TtsTask {
|
|||||||
|
|
||||||
const onPlaybackStart = (evt) => {
|
const onPlaybackStart = (evt) => {
|
||||||
try {
|
try {
|
||||||
|
const playbackId = this.getPlaybackId(segment);
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
const unmatchedResponse = (!!this.playbackId && !!evt.variable_tts_playback_id) && evt.variable_tts_playback_id !== this.playbackId;
|
const unmatchedResponse = (!!playbackId && !!evt.variable_tts_playback_id) && evt.variable_tts_playback_id !== playbackId;
|
||||||
if (unmatchedResponse) {
|
if (unmatchedResponse) {
|
||||||
this.logger.info({currentPlaybackId: this.playbackId, stopPlaybackId: evt.variable_tts_playback_id},
|
this.logger.info({currentPlaybackId: playbackId, stopPlaybackId: evt.variable_tts_playback_id},
|
||||||
'Say:exec playback-start - unmatched playback_id');
|
'Say:exec playback-start - unmatched playback_id');
|
||||||
ep.once('playback-start', this._boundOnPlaybackStart);
|
ep.once('playback-start', this._boundOnPlaybackStart);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ class TtsTask extends Task {
|
|||||||
this.disableTtsCache = this.data.disableTtsCache;
|
this.disableTtsCache = this.data.disableTtsCache;
|
||||||
this.options = this.synthesizer.options || {};
|
this.options = this.synthesizer.options || {};
|
||||||
this.instructions = this.data.instructions;
|
this.instructions = this.data.instructions;
|
||||||
|
this.playbackIds = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlaybackId(offset) {
|
||||||
|
return this.playbackIds[offset];
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(cs) {
|
async exec(cs) {
|
||||||
@@ -290,6 +295,7 @@ class TtsTask extends Task {
|
|||||||
renderForCaching: preCache
|
renderForCaching: preCache
|
||||||
});
|
});
|
||||||
if (!filePath.startsWith('say:')) {
|
if (!filePath.startsWith('say:')) {
|
||||||
|
this.playbackIds.push(null);
|
||||||
this.logger.debug(`Say: file ${filePath}, served from cache ${servedFromCache}`);
|
this.logger.debug(`Say: file ${filePath}, served from cache ${servedFromCache}`);
|
||||||
if (filePath) cs.trackTmpFile(filePath);
|
if (filePath) cs.trackTmpFile(filePath);
|
||||||
if (this.otelSpan) {
|
if (this.otelSpan) {
|
||||||
@@ -319,8 +325,8 @@ class TtsTask extends Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.playbackId = extractPlaybackId(filePath);
|
this.playbackIds.push(extractPlaybackId(filePath));
|
||||||
this.logger.debug(`Say: a streaming tts api will be used, playback_id=${this.playbackId}`);
|
this.logger.debug({playbackIds: this.playbackIds}, 'Say: a streaming tts api will be used');
|
||||||
const modifiedPath = filePath.replace('say:{', `say:{session-uuid=${ep.uuid},`);
|
const modifiedPath = filePath.replace('say:{', `say:{session-uuid=${ep.uuid},`);
|
||||||
return modifiedPath;
|
return modifiedPath;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user