mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
support dial translate
This commit is contained in:
@@ -110,6 +110,7 @@ class TaskDial extends Task {
|
||||
this.tag = this.data.tag;
|
||||
this.boostAudioSignal = this.data.boostAudioSignal;
|
||||
this._mediaPath = MediaPath.FullMedia;
|
||||
this.translate = this.data.translate;
|
||||
|
||||
if (this.dtmfHook) {
|
||||
const {parentDtmfCollector, childDtmfCollector} = parseDtmfOptions(logger, this.data.dtmfCapture || {});
|
||||
@@ -158,6 +159,7 @@ class TaskDial extends Task {
|
||||
|
||||
get canReleaseMedia() {
|
||||
const keepAnchor = this.data.anchorMedia ||
|
||||
this.data.translate ||
|
||||
this.cs.isBackGroundListen ||
|
||||
this.cs.onHoldMusic ||
|
||||
ANCHOR_MEDIA_ALWAYS ||
|
||||
@@ -291,6 +293,17 @@ class TaskDial extends Task {
|
||||
this.transcribeTask.span.end();
|
||||
this.transcribeTask = null;
|
||||
}
|
||||
if (this.llmTask) {
|
||||
await this.llmTask.kill(cs);
|
||||
this.llmTask.span.end();
|
||||
this.llmTask = null;
|
||||
}
|
||||
|
||||
if (this.sdLlmTask) {
|
||||
await this.sdLlmTask.kill(cs);
|
||||
this.sdLlmTask.span.end();
|
||||
this.sdLlmTask = null;
|
||||
}
|
||||
this.notifyTaskDone();
|
||||
}
|
||||
|
||||
@@ -758,6 +771,30 @@ class TaskDial extends Task {
|
||||
this._killOutdials(); // NB: order is important
|
||||
}
|
||||
|
||||
async _startTranslate(cs, sd) {
|
||||
if (this.translate) {
|
||||
const {callerLanguage, calleeLanguage, gain} = this.translate;
|
||||
assert(this.translate.llm, 'Dial:_startTranslate - missing llm in translate');
|
||||
this.logger.debug('Dial:_startTranslate start llm services');
|
||||
// setup caller LLM task
|
||||
this.llmTask = makeTask(this.logger, {'llm': this.translate.llm});
|
||||
this.llmTask.configureDialTranslate({
|
||||
language: callerLanguage,
|
||||
gain,
|
||||
});
|
||||
|
||||
// setup callee LLM task
|
||||
this.sdLlmTask = makeTask(this.logger, {'llm': this.translate.llm});
|
||||
this.sdLlmTask.configureDialTranslate({
|
||||
language: calleeLanguage,
|
||||
gain,
|
||||
});
|
||||
|
||||
this.llmTask.exec(cs, {ep: this.ep});
|
||||
this.sdLlmTask.exec(cs, {ep: sd.ep});
|
||||
}
|
||||
}
|
||||
|
||||
async _onReinvite(req, res) {
|
||||
try {
|
||||
let isHandled = false;
|
||||
|
||||
Reference in New Issue
Block a user