mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-01-25 02:07:56 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4726cbf1d | ||
|
|
2800c4cc4c | ||
|
|
b4b096d07c | ||
|
|
10b5ceeef1 | ||
|
|
ea954eca0b | ||
|
|
d93da88bff | ||
|
|
10fb6b1e67 |
@@ -174,61 +174,5 @@
|
||||
"non è raggiungibile",
|
||||
"lascia pure un messaggio",
|
||||
"puoi lasciare un messaggio"
|
||||
],
|
||||
"ja-JP": [
|
||||
"この通話は留守番電話に転送されました",
|
||||
"発信先は現在電話に出ることができません",
|
||||
"発信音の後でメッセージを録音してください",
|
||||
"録音を完了したら電話を切ることができます",
|
||||
"只今電話に出ることができません",
|
||||
"ただ今電話に出ることができません",
|
||||
"ただいま電話に出ることができません",
|
||||
"ピーという発信音の後にお名前とご用件をお話しください",
|
||||
"ファックスを送られる方はスタートボタンを押してください",
|
||||
"FAXを送られる方はスタートボタンを押してください",
|
||||
"おかけになった電話をお呼びしましたが",
|
||||
"お出になりません",
|
||||
"おでになりません",
|
||||
"お掛けになった電話番号は",
|
||||
"おかけになった電話番号は",
|
||||
"お掛けになった電話は",
|
||||
"おかけになった電話は",
|
||||
"現在使われておりません",
|
||||
"番号をお確かめになって",
|
||||
"お掛け直し下さい",
|
||||
"おかけ直し下さい",
|
||||
"おかけ直しください",
|
||||
"こちらはNTTドコモです",
|
||||
"こちらはエーユーです",
|
||||
"こちらはソフトバンクです",
|
||||
"電波の届かない",
|
||||
"電源が入っていない",
|
||||
"掛かりません",
|
||||
"かかりません",
|
||||
"お繋ぎすることが出来ません",
|
||||
"お繋ぎ出来ません",
|
||||
"お繋ぎすることができません",
|
||||
"お繋ぎできません",
|
||||
"おつなぎすることができません",
|
||||
"おつなぎできません",
|
||||
"メッセージを録音",
|
||||
"留守番電話",
|
||||
"お留守番サービス",
|
||||
"留守番",
|
||||
"留守電",
|
||||
"留守",
|
||||
"接続します",
|
||||
"合図の音",
|
||||
"ピーと",
|
||||
"発信音",
|
||||
"ご用件",
|
||||
"伝言",
|
||||
"お話しください",
|
||||
"ファックス",
|
||||
"FAX",
|
||||
"終了",
|
||||
"終了しました",
|
||||
"終了いたしました",
|
||||
"営業時間"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ router.post('/',
|
||||
|
||||
// find handling sbc sip for called user
|
||||
if (JAMBONES_DIAL_SBC_FOR_REGISTERED_USER && target.type === 'user') {
|
||||
const { registrar} = srf.locals.dbHelpers;
|
||||
const { registrar } = srf.locals.dbHelpers;
|
||||
const reg = await registrar.query(target.name);
|
||||
if (reg) {
|
||||
sbcAddress = selectHostPort(logger, reg.sbcAddress, 'tcp')[1];
|
||||
@@ -159,9 +159,7 @@ router.post('/',
|
||||
* trunk isn't specified,
|
||||
* check if from-number matches any existing numbers on Jambonz
|
||||
* */
|
||||
const { lookupLcrByAccount} = srf.locals.dbHelpers;
|
||||
const lcrs = await lookupLcrByAccount(req.body.account_sid);
|
||||
if (target.type === 'phone' && !target.trunk && lcrs.length == 0) {
|
||||
if (target.type === 'phone' && !target.trunk) {
|
||||
const str = restDial.from || '';
|
||||
const callingNumber = str.startsWith('+') ? str.substring(1) : str;
|
||||
const voip_carrier_sid = await lookupCarrierByPhoneNumber(req.body.account_sid, callingNumber);
|
||||
|
||||
@@ -710,7 +710,7 @@ class CallSession extends Emitter {
|
||||
}
|
||||
|
||||
|
||||
get hasGlobalSttPunctuation() {
|
||||
hasGlobalSttPunctuation() {
|
||||
return this._globalSttPunctuation !== undefined;
|
||||
}
|
||||
|
||||
@@ -1017,6 +1017,8 @@ class CallSession extends Emitter {
|
||||
(type === 'tts' && credential.use_for_tts) ||
|
||||
(type === 'stt' && credential.use_for_stt)
|
||||
)) {
|
||||
this.logger.debug(
|
||||
`${type}: ${credential.vendor} ${credential.label ? `, label: ${credential.label}` : ''} `);
|
||||
if ('google' === vendor) {
|
||||
if (type === 'tts' && !credential.tts_tested_ok ||
|
||||
type === 'stt' && !credential.stt_tested_ok) {
|
||||
@@ -1165,7 +1167,7 @@ class CallSession extends Emitter {
|
||||
service_version: credential.service_version
|
||||
};
|
||||
}
|
||||
else if ('deepgramflux' === vendor) {
|
||||
else if ('deepgramriver' === vendor) {
|
||||
return {
|
||||
speech_credential_sid: credential.speech_credential_sid,
|
||||
api_key: credential.api_key,
|
||||
@@ -1415,11 +1417,7 @@ class CallSession extends Emitter {
|
||||
}
|
||||
else {
|
||||
if (this.req && !this.dlg) {
|
||||
try {
|
||||
this.req.cancel();
|
||||
} catch (err) {
|
||||
this.logger.error({err}, 'CallSession:_lccCallStatus error cancelling request');
|
||||
}
|
||||
this.req.cancel();
|
||||
this._callReleased();
|
||||
}
|
||||
}
|
||||
@@ -1866,7 +1864,7 @@ Duration=${duration} `
|
||||
return;
|
||||
}
|
||||
else if (tokens === undefined) {
|
||||
this.logger.info({opts}, 'CallSession:_lccTtsTokens - invalid command since tokens is missing');
|
||||
this.logger.info({opts}, 'CallSession:_lccTtsTokens - invalid command since id is missing');
|
||||
return this.requestor.request('tts:tokens-result', '/tokens-result', {
|
||||
id,
|
||||
status: 'failed',
|
||||
@@ -2399,7 +2397,7 @@ Duration=${duration} `
|
||||
this.logger.debug(`endpoint was destroyed!! ${this.ep.uuid}`);
|
||||
});
|
||||
|
||||
if (this.direction === CallDirection.Inbound || this.application?.transferredCall) {
|
||||
if (this.direction === CallDirection.Inbound) {
|
||||
if (task.earlyMedia && !this.req.finalResponseSent) {
|
||||
this.res.send(183, {body: ep.local.sdp});
|
||||
return {ep};
|
||||
@@ -2685,7 +2683,7 @@ Duration=${duration} `
|
||||
*/
|
||||
_onRefer(req, res) {
|
||||
const task = this.currentTask;
|
||||
const sd = task?.sd;
|
||||
const sd = task.sd;
|
||||
if (task && TaskName.Dial === task.name && sd && task.referHook) {
|
||||
task.handleRefer(this, req, res);
|
||||
}
|
||||
@@ -3084,7 +3082,7 @@ Duration=${duration} `
|
||||
task.notifyTtsStreamIsEmpty();
|
||||
} else if (
|
||||
// If Gather nested say task is streaming
|
||||
task && TaskName.Gather === task.name && task.sayTask && task.sayTask.isStreamingTts) {
|
||||
TaskName.Gather === task.name && task.sayTask && task.sayTask.isStreamingTts) {
|
||||
const sayTask = task.sayTask;
|
||||
sayTask.notifyTtsStreamIsEmpty();
|
||||
}
|
||||
|
||||
@@ -641,9 +641,7 @@ class TaskDial extends Task {
|
||||
* trunk isn't specified,
|
||||
* check if number matches any existing numbers
|
||||
* */
|
||||
const { lookupLcrByAccount} = srf.locals.dbHelpers;
|
||||
const lcrs = await lookupLcrByAccount(cs.accountSid);
|
||||
if (t.type === 'phone' && !t.trunk && lcrs.length == 0) {
|
||||
if (t.type === 'phone' && !t.trunk) {
|
||||
const str = this.callerId || req.callingNumber || '';
|
||||
const callingNumber = str.startsWith('+') ? str.substring(1) : str;
|
||||
const voip_carrier_sid = await lookupCarrierByPhoneNumber(cs.accountSid, callingNumber);
|
||||
@@ -676,8 +674,7 @@ class TaskDial extends Task {
|
||||
rootSpan: cs.rootSpan,
|
||||
startSpan: this.startSpan.bind(this),
|
||||
dialTask: this,
|
||||
onHoldMusic: this.cs.onHoldMusic,
|
||||
tmpFiles: this.cs.tmpFiles,
|
||||
onHoldMusic: this.cs.onHoldMusic
|
||||
});
|
||||
this.dials.set(sd.callSid, sd);
|
||||
|
||||
@@ -778,9 +775,6 @@ class TaskDial extends Task {
|
||||
this.epOther.api('uuid_break', this.epOther.uuid);
|
||||
this.epOther.bridge(sd.ep);
|
||||
}
|
||||
else {
|
||||
this.logger.error('Dial:_connectSingleDial - no other endpoint to bridge!');
|
||||
}
|
||||
this.bridged = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const {
|
||||
NvidiaTranscriptionEvents,
|
||||
JambonzTranscriptionEvents,
|
||||
AssemblyAiTranscriptionEvents,
|
||||
DeepgramfluxTranscriptionEvents,
|
||||
DeepgramRiverTranscriptionEvents,
|
||||
VoxistTranscriptionEvents,
|
||||
CartesiaTranscriptionEvents,
|
||||
OpenAITranscriptionEvents,
|
||||
@@ -395,7 +395,6 @@ class TaskGather extends SttTask {
|
||||
if (this.digitBuffer.length === 0 && this.needsStt) {
|
||||
// DTMF is higher priority than STT.
|
||||
this.removeCustomEventListeners();
|
||||
this._clearAsrTimer(); //clear ASR timer as we're now using dtmf
|
||||
this._stopTranscribing(ep);
|
||||
}
|
||||
this.digitBuffer += evt.dtmf;
|
||||
@@ -410,7 +409,6 @@ class TaskGather extends SttTask {
|
||||
const ms = this.interDigitTimeout * 1000;
|
||||
this.logger.debug(`starting interdigit timer of ${ms}`);
|
||||
this.interDigitTimer = setTimeout(() => this._resolve('dtmf-interdigit-timeout'), ms);
|
||||
this._clearTimer(); //clear main timer as we're now using interdigit dtmf timer
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,18 +466,16 @@ class TaskGather extends SttTask {
|
||||
this.addCustomEventListener(ep, DeepgramTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep));
|
||||
this.addCustomEventListener(ep, DeepgramTranscriptionEvents.ConnectFailure,
|
||||
this._onVendorConnectFailure.bind(this, cs, ep));
|
||||
this.addCustomEventListener(ep, DeepgramTranscriptionEvents.Error, this._onVendorError.bind(this, cs, ep));
|
||||
break;
|
||||
|
||||
case 'deepgramflux':
|
||||
this.bugname = `${this.bugname_prefix}deepgramflux_transcribe`;
|
||||
case 'deepgramriver':
|
||||
this.bugname = `${this.bugname_prefix}deepgramriver_transcribe`;
|
||||
this.addCustomEventListener(
|
||||
ep, DeepgramfluxTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep));
|
||||
ep, DeepgramRiverTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep));
|
||||
this.addCustomEventListener(
|
||||
ep, DeepgramfluxTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep));
|
||||
this.addCustomEventListener(ep, DeepgramfluxTranscriptionEvents.ConnectFailure,
|
||||
ep, DeepgramRiverTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep));
|
||||
this.addCustomEventListener(ep, DeepgramRiverTranscriptionEvents.ConnectFailure,
|
||||
this._onVendorConnectFailure.bind(this, cs, ep));
|
||||
this.addCustomEventListener(ep, DeepgramfluxTranscriptionEvents.Error, this._onVendorError.bind(this, cs, ep));
|
||||
break;
|
||||
|
||||
case 'soniox':
|
||||
@@ -706,8 +702,8 @@ class TaskGather extends SttTask {
|
||||
this.logger.debug(`Starting timoutTimer of ${this.timeout}ms`);
|
||||
this._clearTimer();
|
||||
this._timeoutTimer = setTimeout(() => {
|
||||
// If continuousASR in use then extend by the asr window for more transcripts.
|
||||
if (this.isContinuousAsr) this._startAsrTimer();
|
||||
if (this.interDigitTimer) return; // let the inter-digit timer complete
|
||||
else {
|
||||
this._resolve(this.digitBuffer.length >= this.minDigits ? 'dtmf-num-digits' : 'timeout');
|
||||
}
|
||||
@@ -914,7 +910,7 @@ class TaskGather extends SttTask {
|
||||
|
||||
evt = this.normalizeTranscription(evt, this.vendor, 1, this.language,
|
||||
this.shortUtterance, this.data.recognizer.punctuation);
|
||||
this.logger.debug({evt, bugname, finished, vendor: this.vendor}, 'Gather:_onTranscription normalized transcript');
|
||||
//this.logger.debug({evt, bugname, finished, vendor: this.vendor}, 'Gather:_onTranscription normalized transcript');
|
||||
|
||||
if (evt.alternatives.length === 0) {
|
||||
this.logger.info({evt}, 'TaskGather:_onTranscription - got empty transcript, continue listening');
|
||||
@@ -1080,11 +1076,6 @@ class TaskGather extends SttTask {
|
||||
this.cs.requestor.request('verb:hook', this.partialResultHook, Object.assign({speech: evt},
|
||||
this.cs.callInfo, httpHeaders));
|
||||
}
|
||||
else if (this.vendor === 'deepgramflux' &&
|
||||
['EagerEndOfTurn', 'TurnResumed'].includes(evt.vendor.evt?.event)) {
|
||||
this.logger.debug(`Gather:_onTranscription - deepgramflux event detected: ${evt.event}`);
|
||||
this.performAction({speech: evt, reason: 'speechDetected'}, false);
|
||||
}
|
||||
if (this.vendor === 'soniox') {
|
||||
if (evt.vendor.finalWords.length) {
|
||||
this.logger.debug({evt}, 'TaskGather:_onTranscription - buffering soniox transcript');
|
||||
|
||||
@@ -19,7 +19,6 @@ class TaskRestDial extends Task {
|
||||
this.timeout = this.data.timeout || 60;
|
||||
this.sipRequestWithinDialogHook = this.data.sipRequestWithinDialogHook;
|
||||
this.referHook = this.data.referHook;
|
||||
this.recentCallStatus = 0;
|
||||
|
||||
this.on('connect', this._onConnect.bind(this));
|
||||
this.on('callStatus', this._onCallStatus.bind(this));
|
||||
@@ -58,11 +57,7 @@ class TaskRestDial extends Task {
|
||||
this._clearCallTimer();
|
||||
if (this.canCancel) {
|
||||
this.canCancel = false;
|
||||
try {
|
||||
cs?.req?.cancel();
|
||||
} catch (err) {
|
||||
this.logger.error({err}, 'TaskRestDial: error cancelling call');
|
||||
}
|
||||
cs?.req?.cancel();
|
||||
}
|
||||
this.notifyTaskDone();
|
||||
}
|
||||
@@ -123,8 +118,7 @@ class TaskRestDial extends Task {
|
||||
}
|
||||
|
||||
_onCallStatus(status) {
|
||||
this.logger.debug(`RestDial CallStatus: ${status}`);
|
||||
this.recentCallStatus = status;
|
||||
this.logger.debug(`CallStatus: ${status}`);
|
||||
if (status >= 200) {
|
||||
this.canCancel = false;
|
||||
this._clearCallTimer();
|
||||
@@ -142,16 +136,11 @@ class TaskRestDial extends Task {
|
||||
}
|
||||
|
||||
_onCallTimeout() {
|
||||
this.logger.debug(`TaskRestDial: timeout expired without answer, last status ${this.recentCallStatus}`);
|
||||
this.logger.debug('TaskRestDial: timeout expired without answer, killing task');
|
||||
this.timer = null;
|
||||
if (this.canCancel && this.recentCallStatus < 200) {
|
||||
this.logger.debug('TaskRestDial: cancelling call attempt');
|
||||
if (this.canCancel) {
|
||||
this.canCancel = false;
|
||||
try {
|
||||
this.cs?.req?.cancel();
|
||||
} catch (err) {
|
||||
this.logger.error({err}, 'TaskRestDial: error cancelling call');
|
||||
}
|
||||
this.cs?.req?.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,28 +5,6 @@ const pollySSMLSplit = require('polly-ssml-split');
|
||||
const { SpeechCredentialError } = require('../utils/error');
|
||||
const { sleepFor } = require('../utils/helpers');
|
||||
|
||||
/**
|
||||
* Discard unmatching responses:
|
||||
* (1) I sent a playback id but get a response with a different playback id
|
||||
* (2) I sent a playback id but get a response with no playback id
|
||||
* (3) I did not send a playback id but get a response with a playback id
|
||||
* (4) I sent a cache file but get a response with a different cache file
|
||||
*/
|
||||
|
||||
const isMatchingEvent = (logger, filename, playbackId, evt) => {
|
||||
|
||||
if (!!playbackId && !!evt.variable_tts_playback_id && evt.variable_tts_playback_id === playbackId) {
|
||||
//logger.debug({filename, playbackId, evt}, 'Say:isMatchingEvent - playbackId matched');
|
||||
return true;
|
||||
}
|
||||
if (!!filename && !!evt.file && evt.file === filename) {
|
||||
//logger.debug({filename, playbackId, evt}, 'Say:isMatchingEvent - filename matched');
|
||||
return true;
|
||||
}
|
||||
logger.info({filename, playbackId, evt}, 'Say:isMatchingEvent - no match');
|
||||
return false;
|
||||
};
|
||||
|
||||
const breakLengthyTextIfNeeded = (logger, text) => {
|
||||
// As The text can be used for tts streaming, we need to break lengthy text into smaller chunks
|
||||
// HIGH_WATER_BUFFER_SIZE defined in tts-streaming-buffer.js
|
||||
@@ -281,32 +259,38 @@ class TaskSay extends TtsTask {
|
||||
while (!this.killed && (this.loop === 'forever' || this.loop--) && ep?.connected) {
|
||||
let segment = 0;
|
||||
while (!this.killed && segment < filepath.length) {
|
||||
const filename = filepath[segment];
|
||||
if (cs.isInConference) {
|
||||
const {memberId, confName, confUuid} = cs;
|
||||
await this.playToConfMember(ep, memberId, confName, confUuid, filename);
|
||||
await this.playToConfMember(ep, memberId, confName, confUuid, filepath[segment]);
|
||||
}
|
||||
else {
|
||||
const isStreaming = filename.startsWith('say:{');
|
||||
const isStreaming = filepath[segment].startsWith('say:{');
|
||||
if (isStreaming) {
|
||||
const arr = /^say:\{.*\}\s*(.*)$/.exec(filename);
|
||||
const arr = /^say:\{.*\}\s*(.*)$/.exec(filepath[segment]);
|
||||
if (arr) this.logger.debug(`Say:exec sending streaming tts request ${arr[1].substring(0, 64)}..`);
|
||||
else this.logger.debug(`Say:exec sending ${filename.substring(0, 64)}`);
|
||||
else this.logger.debug(`Say:exec sending ${filepath[segment].substring(0, 64)}`);
|
||||
}
|
||||
|
||||
const onPlaybackStop = (evt) => {
|
||||
try {
|
||||
this.logger.debug({evt},
|
||||
`Say got playback-stop ${evt.variable_tts_playback_id ? evt.variable_tts_playback_id : ''}`);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const playbackId = this.getPlaybackId(segment);
|
||||
const isMatch = isMatchingEvent(this.logger, filename, playbackId, evt);
|
||||
if (!isMatch) {
|
||||
// eslint-disable-next-line max-len
|
||||
const unmatchedResponse = (!!playbackId && !!evt.variable_tts_playback_id) && evt.variable_tts_playback_id !== playbackId;
|
||||
if (unmatchedResponse) {
|
||||
this.logger.info({currentPlaybackId: playbackId, stopPlaybackId: evt.variable_tts_playback_id},
|
||||
'Say:exec discarding playback-stop for earlier play');
|
||||
ep.once('playback-stop', this._boundOnPlaybackStop);
|
||||
|
||||
return;
|
||||
}
|
||||
this.logger.debug({evt},
|
||||
`Say got playback-stop ${evt.variable_tts_playback_id ? evt.variable_tts_playback_id : ''}`);
|
||||
|
||||
this.notifyStatus({event: 'stop-playback'});
|
||||
this.notifiedPlayBackStop = true;
|
||||
const tts_error = evt.variable_tts_error;
|
||||
@@ -345,7 +329,6 @@ class TaskSay extends TtsTask {
|
||||
!this.disableTtsCache
|
||||
) {
|
||||
const text = parseTextFromSayString(this.text[segment]);
|
||||
this.logger.debug({text, cacheFile: evt.variable_tts_cache_filename}, 'Say:exec cache tts');
|
||||
addFileToCache(evt.variable_tts_cache_filename, {
|
||||
account_sid,
|
||||
vendor,
|
||||
@@ -376,14 +359,14 @@ class TaskSay extends TtsTask {
|
||||
const onPlaybackStart = (evt) => {
|
||||
try {
|
||||
const playbackId = this.getPlaybackId(segment);
|
||||
const isMatch = isMatchingEvent(this.logger, filename, playbackId, evt);
|
||||
if (!isMatch) {
|
||||
this.logger.info({currentPlaybackId: playbackId, startPlaybackId: evt.variable_tts_playback_id},
|
||||
// eslint-disable-next-line max-len
|
||||
const unmatchedResponse = (!!playbackId && !!evt.variable_tts_playback_id) && evt.variable_tts_playback_id !== playbackId;
|
||||
if (unmatchedResponse) {
|
||||
this.logger.info({currentPlaybackId: playbackId, stopPlaybackId: evt.variable_tts_playback_id},
|
||||
'Say:exec playback-start - unmatched playback_id');
|
||||
ep.once('playback-start', this._boundOnPlaybackStart);
|
||||
return;
|
||||
}
|
||||
ep.once('playback-stop', this._boundOnPlaybackStop);
|
||||
this.logger.debug({evt},
|
||||
`Say got playback-start ${evt.variable_tts_playback_id ? evt.variable_tts_playback_id : ''}`);
|
||||
if (this.otelSpan) {
|
||||
@@ -400,6 +383,7 @@ class TaskSay extends TtsTask {
|
||||
};
|
||||
this._boundOnPlaybackStart = onPlaybackStart.bind(this);
|
||||
|
||||
ep.once('playback-stop', this._boundOnPlaybackStop);
|
||||
ep.once('playback-start', this._boundOnPlaybackStart);
|
||||
|
||||
// wait for playback-stop event received to confirm if the playback is successful
|
||||
@@ -407,11 +391,8 @@ class TaskSay extends TtsTask {
|
||||
this._playResolve = resolve;
|
||||
this._playReject = reject;
|
||||
});
|
||||
const r = await ep.play(filename);
|
||||
const r = await ep.play(filepath[segment]);
|
||||
this.logger.debug({r}, 'Say:exec play result');
|
||||
if (r.playbackSeconds == null && r.playbackMilliseconds == null && r.playbackLastOffsetPos == null) {
|
||||
this._playReject(new Error('Playback failed to start'));
|
||||
}
|
||||
try {
|
||||
// wait for playback-stop event received to confirm if the playback is successful
|
||||
await this._playPromise;
|
||||
@@ -428,12 +409,12 @@ class TaskSay extends TtsTask {
|
||||
this._playResolve = null;
|
||||
this._playReject = null;
|
||||
}
|
||||
if (filename.startsWith('say:{')) {
|
||||
const arr = /^say:\{.*\}\s*(.*)$/.exec(filename);
|
||||
if (filepath[segment].startsWith('say:{')) {
|
||||
const arr = /^say:\{.*\}\s*(.*)$/.exec(filepath[segment]);
|
||||
if (arr) this.logger.debug(`Say:exec complete playing streaming tts request: ${arr[1].substring(0, 64)}..`);
|
||||
} else {
|
||||
// This log will print spech credentials in say command for tts stream mode
|
||||
this.logger.debug(`Say:exec completed play file ${filename}`);
|
||||
this.logger.debug(`Say:exec completed play file ${filepath[segment]}`);
|
||||
}
|
||||
}
|
||||
segment++;
|
||||
|
||||
@@ -6,7 +6,7 @@ const {
|
||||
AwsTranscriptionEvents,
|
||||
AzureTranscriptionEvents,
|
||||
DeepgramTranscriptionEvents,
|
||||
DeepgramfluxTranscriptionEvents,
|
||||
DeepgramRiverTranscriptionEvents,
|
||||
SonioxTranscriptionEvents,
|
||||
CobaltTranscriptionEvents,
|
||||
IbmTranscriptionEvents,
|
||||
@@ -237,23 +237,19 @@ class TaskTranscribe extends SttTask {
|
||||
this._onVendorConnect.bind(this, cs, ep));
|
||||
this.addCustomEventListener(ep, DeepgramTranscriptionEvents.ConnectFailure,
|
||||
this._onVendorConnectFailure.bind(this, cs, ep, channel));
|
||||
this.addCustomEventListener(ep, DeepgramTranscriptionEvents.Error, this._onVendorError.bind(this, cs, ep));
|
||||
|
||||
|
||||
/* if app sets deepgramOptions.utteranceEndMs they essentially want continuous asr */
|
||||
//if (opts.DEEPGRAM_SPEECH_UTTERANCE_END_MS) this.isContinuousAsr = true;
|
||||
|
||||
break;
|
||||
case 'deepgramflux':
|
||||
this.bugname = `${this.bugname_prefix}deepgramflux_transcribe`;
|
||||
this.addCustomEventListener(ep, DeepgramfluxTranscriptionEvents.Transcription,
|
||||
case 'deepgramriver':
|
||||
this.bugname = `${this.bugname_prefix}deepgramriver_transcribe`;
|
||||
this.addCustomEventListener(ep, DeepgramRiverTranscriptionEvents.Transcription,
|
||||
this._onTranscription.bind(this, cs, ep, channel));
|
||||
this.addCustomEventListener(ep, DeepgramfluxTranscriptionEvents.Connect,
|
||||
this.addCustomEventListener(ep, DeepgramRiverTranscriptionEvents.Connect,
|
||||
this._onVendorConnect.bind(this, cs, ep));
|
||||
this.addCustomEventListener(ep, DeepgramfluxTranscriptionEvents.ConnectFailure,
|
||||
this.addCustomEventListener(ep, DeepgramRiverTranscriptionEvents.ConnectFailure,
|
||||
this._onVendorConnectFailure.bind(this, cs, ep, channel));
|
||||
this.addCustomEventListener(ep, DeepgramfluxTranscriptionEvents.Error, this._onVendorError.bind(this, cs, ep));
|
||||
|
||||
break;
|
||||
case 'soniox':
|
||||
this.bugname = `${this.bugname_prefix}soniox_transcribe`;
|
||||
|
||||
@@ -84,7 +84,8 @@ class TtsTask extends Task {
|
||||
const {api_key, model_id, custom_tts_streaming_url, auth_token} = credentials;
|
||||
let obj;
|
||||
|
||||
this.logger.debug(`setTtsStreamingChannelVars: vendor: ${vendor}, language: ${language}, voice: ${voice}`);
|
||||
this.logger.debug({credentials},
|
||||
`setTtsStreamingChannelVars: vendor: ${vendor}, language: ${language}, voice: ${voice}`);
|
||||
|
||||
switch (vendor) {
|
||||
case 'deepgram':
|
||||
@@ -327,13 +328,6 @@ class TtsTask extends Task {
|
||||
this.playbackIds.push(extractPlaybackId(filePath));
|
||||
this.logger.debug({playbackIds: this.playbackIds}, 'Say: a streaming tts api will be used');
|
||||
const modifiedPath = filePath.replace('say:{', `say:{session-uuid=${ep.uuid},`);
|
||||
this.notifyStatus({
|
||||
event: 'synthesized-audio',
|
||||
vendor,
|
||||
language,
|
||||
servedFromCache,
|
||||
'id': this.id
|
||||
});
|
||||
return modifiedPath;
|
||||
}
|
||||
return filePath;
|
||||
|
||||
@@ -94,14 +94,12 @@
|
||||
"DeepgramTranscriptionEvents": {
|
||||
"Transcription": "deepgram_transcribe::transcription",
|
||||
"ConnectFailure": "deepgram_transcribe::connect_failed",
|
||||
"Connect": "deepgram_transcribe::connect",
|
||||
"Error": "deepgram_transcribe::error"
|
||||
"Connect": "deepgram_transcribe::connect"
|
||||
},
|
||||
"DeepgramfluxTranscriptionEvents": {
|
||||
"Transcription": "deepgramflux_transcribe::transcription",
|
||||
"ConnectFailure": "deepgramflux_transcribe::connect_failed",
|
||||
"Connect": "deepgramflux_transcribe::connect",
|
||||
"Error": "deepgramflux_transcribe::error"
|
||||
"DeepgramRiverTranscriptionEvents": {
|
||||
"Transcription": "deepgramriver_transcribe::transcription",
|
||||
"ConnectFailure": "deepgramriver_transcribe::connect_failed",
|
||||
"Connect": "deepgramriver_transcribe::connect"
|
||||
},
|
||||
"SonioxTranscriptionEvents": {
|
||||
"Transcription": "soniox_transcribe::transcription",
|
||||
|
||||
@@ -81,7 +81,7 @@ const speechMapper = (cred) => {
|
||||
obj.deepgram_tts_uri = o.deepgram_tts_uri;
|
||||
obj.deepgram_stt_use_tls = o.deepgram_stt_use_tls;
|
||||
}
|
||||
else if ('deepgramflux' === obj.vendor) {
|
||||
else if ('deepgramriver' === obj.vendor) {
|
||||
const o = JSON.parse(decrypt(credential));
|
||||
obj.api_key = o.api_key;
|
||||
}
|
||||
|
||||
@@ -173,8 +173,7 @@ function installSrfLocals(srf, logger, {
|
||||
lookupAccountCapacitiesBySid,
|
||||
lookupSmppGateways,
|
||||
lookupClientByAccountAndUsername,
|
||||
lookupSystemInformation,
|
||||
lookupLcrByAccount
|
||||
lookupSystemInformation
|
||||
} = require('@jambonz/db-helpers')({
|
||||
host: JAMBONES_MYSQL_HOST,
|
||||
user: JAMBONES_MYSQL_USER,
|
||||
@@ -280,8 +279,7 @@ function installSrfLocals(srf, logger, {
|
||||
retrieveByPatternSortedSet,
|
||||
sortedSetLength,
|
||||
sortedSetPositionByPattern,
|
||||
getVerbioAccessToken,
|
||||
lookupLcrByAccount
|
||||
getVerbioAccessToken
|
||||
},
|
||||
parentLogger: logger,
|
||||
getSBC,
|
||||
|
||||
@@ -20,7 +20,7 @@ const { createMediaEndpoint } = require('./media-endpoint');
|
||||
|
||||
class SingleDialer extends Emitter {
|
||||
constructor({logger, sbcAddress, target, opts, application, callInfo, accountInfo, rootSpan, startSpan, dialTask,
|
||||
onHoldMusic, tmpFiles}) {
|
||||
onHoldMusic}) {
|
||||
super();
|
||||
assert(target.type);
|
||||
|
||||
@@ -44,7 +44,6 @@ class SingleDialer extends Emitter {
|
||||
this.callSid = crypto.randomUUID();
|
||||
this.dialTask = dialTask;
|
||||
this.onHoldMusic = onHoldMusic;
|
||||
this.tmpFiles = tmpFiles;
|
||||
|
||||
this.on('callStatusChange', this._notifyCallStatusChange.bind(this));
|
||||
}
|
||||
@@ -329,13 +328,7 @@ class SingleDialer extends Emitter {
|
||||
*/
|
||||
async kill(Reason) {
|
||||
this.killed = true;
|
||||
if (this.inviteInProgress) {
|
||||
try {
|
||||
await this.inviteInProgress.cancel();
|
||||
} catch (err) {
|
||||
this.logger.error({err}, 'SingleDialer:kill error cancelling invite');
|
||||
}
|
||||
}
|
||||
if (this.inviteInProgress) await this.inviteInProgress.cancel();
|
||||
else if (this.dlg && this.dlg.connected) {
|
||||
const duration = moment().diff(this.dlg.connectTime, 'seconds');
|
||||
this.logger.debug('SingleDialer:kill hanging up called party');
|
||||
@@ -409,7 +402,7 @@ class SingleDialer extends Emitter {
|
||||
tasks,
|
||||
rootSpan: this.rootSpan,
|
||||
req: this.req,
|
||||
tmpFiles: this.tmpFiles,
|
||||
tmpFiles: cs.tmpFiles,
|
||||
});
|
||||
await cs.exec();
|
||||
|
||||
@@ -543,12 +536,12 @@ class SingleDialer extends Emitter {
|
||||
|
||||
function placeOutdial({
|
||||
logger, srf, ms, sbcAddress, target, opts, application, callInfo, accountInfo, rootSpan, startSpan, dialTask,
|
||||
onHoldMusic, tmpFiles
|
||||
onHoldMusic
|
||||
}) {
|
||||
const myOpts = deepcopy(opts);
|
||||
const sd = new SingleDialer({
|
||||
logger, sbcAddress, target, opts: myOpts, application, callInfo,
|
||||
accountInfo, rootSpan, startSpan, dialTask, onHoldMusic, tmpFiles
|
||||
accountInfo, rootSpan, startSpan, dialTask, onHoldMusic
|
||||
});
|
||||
sd.exec(srf, ms, myOpts);
|
||||
return sd;
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
// lib/utils/process-monitor.js
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
class ProcessMonitor {
|
||||
constructor(logger) {
|
||||
this.logger = logger;
|
||||
this.packageInfo = this.getPackageInfo();
|
||||
this.processName = this.packageInfo.name || 'unknown-app';
|
||||
}
|
||||
|
||||
getPackageInfo() {
|
||||
try {
|
||||
const packagePath = path.join(process.cwd(), 'package.json');
|
||||
return JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
||||
} catch (e) {
|
||||
return { name: 'unknown', version: 'unknown' };
|
||||
}
|
||||
}
|
||||
|
||||
logStartup(additionalInfo = {}) {
|
||||
const startupInfo = {
|
||||
msg: `${this.processName} started`,
|
||||
app_name: this.processName,
|
||||
app_version: this.packageInfo.version,
|
||||
pid: process.pid,
|
||||
ppid: process.ppid,
|
||||
pm2_instance_id: process.env.NODE_APP_INSTANCE || 'not_pm2',
|
||||
pm2_id: process.env.pm_id,
|
||||
is_pm2: !!process.env.PM2,
|
||||
node_version: process.version,
|
||||
uptime: process.uptime(),
|
||||
timestamp: new Date().toISOString(),
|
||||
...additionalInfo
|
||||
};
|
||||
|
||||
this.logger.info(startupInfo);
|
||||
return startupInfo;
|
||||
}
|
||||
|
||||
setupSignalHandlers() {
|
||||
// Log when we receive signals that would cause restart
|
||||
process.on('SIGINT', () => {
|
||||
this.logger.info({
|
||||
msg: 'SIGINT received',
|
||||
app_name: this.processName,
|
||||
pid: process.pid,
|
||||
ppid: process.ppid,
|
||||
uptime: process.uptime(),
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on('SIGTERM', () => {
|
||||
this.logger.info({
|
||||
msg: 'SIGTERM received',
|
||||
app_name: this.processName,
|
||||
pid: process.pid,
|
||||
ppid: process.ppid,
|
||||
uptime: process.uptime(),
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', (error) => {
|
||||
this.logger.error({
|
||||
msg: 'Uncaught exception - process will restart',
|
||||
app_name: this.processName,
|
||||
error: error.message,
|
||||
stack: error.stack,
|
||||
pid: process.pid,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (reason, promise) => {
|
||||
this.logger.error({
|
||||
msg: 'Unhandled rejection',
|
||||
app_name: this.processName,
|
||||
reason,
|
||||
pid: process.pid,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ProcessMonitor;
|
||||
|
||||
@@ -339,32 +339,20 @@ const normalizeDeepgram = (evt, channel, language, shortUtterance) => {
|
||||
};
|
||||
};
|
||||
|
||||
const normalizeDeepgramFlux = (evt, channel, language) => {
|
||||
const normalizeDeepgramRiver = (evt, channel, language, shortUtterance) => {
|
||||
const copy = JSON.parse(JSON.stringify(evt));
|
||||
|
||||
let turnTakingEvent;
|
||||
if (['StartOfTurn', 'EagerEndOfTurn', 'TurnResumed', 'EndOfTurn'].includes(evt.event)) {
|
||||
turnTakingEvent = evt.event;
|
||||
}
|
||||
|
||||
/* calculate total confidence based on word-level confidence */
|
||||
const realWords = (evt.words || [])
|
||||
.filter((w) => ![',.!?;'].includes(w.word));
|
||||
const confidence = realWords.length > 0 ? realWords.reduce((acc, w) => acc + w.confidence, 0) / realWords.length : 0;
|
||||
return {
|
||||
language_code: language,
|
||||
channel_tag: channel,
|
||||
is_final: evt.event === 'EndOfTurn',
|
||||
alternatives: [
|
||||
{
|
||||
confidence,
|
||||
end_of_turn_confidence: evt.end_of_turn_confidence,
|
||||
confidence: evt.end_of_turn_confidence,
|
||||
transcript: evt.transcript,
|
||||
...(turnTakingEvent && {turn_taking_event: turnTakingEvent})
|
||||
}
|
||||
],
|
||||
vendor: {
|
||||
name: 'deepgramflux',
|
||||
name: 'deepgramriver',
|
||||
evt: copy
|
||||
}
|
||||
};
|
||||
@@ -681,8 +669,8 @@ module.exports = (logger) => {
|
||||
switch (vendor) {
|
||||
case 'deepgram':
|
||||
return normalizeDeepgram(evt, channel, language, shortUtterance);
|
||||
case 'deepgramflux':
|
||||
return normalizeDeepgramFlux(evt, channel, language, shortUtterance);
|
||||
case 'deepgramriver':
|
||||
return normalizeDeepgramRiver(evt, channel, language, shortUtterance);
|
||||
case 'microsoft':
|
||||
return normalizeMicrosoft(evt, channel, language, punctuation);
|
||||
case 'google':
|
||||
@@ -977,23 +965,19 @@ module.exports = (logger) => {
|
||||
...(entityPrompt && {DEEPGRAM_SPEECH_ENTITY_PROMPT: entityPrompt}),
|
||||
};
|
||||
}
|
||||
else if ('deepgramflux' === vendor) {
|
||||
else if ('deepgramriver' === vendor) {
|
||||
const {
|
||||
preflightThreshold,
|
||||
eotThreshold,
|
||||
eotTimeoutMs,
|
||||
mipOptOut,
|
||||
model,
|
||||
eagerEotThreshold,
|
||||
keyterms
|
||||
mipOptOut
|
||||
} = rOpts.deepgramOptions || {};
|
||||
opts = {
|
||||
DEEPGRAMFLUX_API_KEY: sttCredentials.api_key,
|
||||
DEEPGRAMFLUX_SPEECH_MODEL: model || 'flux-general-en',
|
||||
...(eotThreshold && {DEEPGRAMFLUX_SPEECH_EOT_THRESHOLD: eotThreshold}),
|
||||
...(eotTimeoutMs && {DEEPGRAMFLUX_SPEECH_EOT_TIMEOUT_MS: eotTimeoutMs}),
|
||||
...(mipOptOut && {DEEPGRAMFLUX_SPEECH_MIP_OPT_OUT: mipOptOut}),
|
||||
...(eagerEotThreshold && {DEEPGRAMFLUX_SPEECH_EAGER_EOT_THRESHOLD: eagerEotThreshold}),
|
||||
...(keyterms && keyterms.length > 0 && {DEEPGRAMFLUX_SPEECH_KEYTERMS: keyterms.join(',')}),
|
||||
DEEPGRAM_API_KEY: sttCredentials.api_key,
|
||||
...(preflightThreshold && {DEEPGRAM_SPEECH_PRELIGHT_THRESHOLD: preflightThreshold}),
|
||||
...(eotThreshold && {DEEPGRAM_SPEECH_EOT_THRESHOLD: eotThreshold}),
|
||||
...(eotTimeoutMs && {DEEPGRAM_SPEECH_EOT_TIMEOUT_MS: eotTimeoutMs}),
|
||||
...(mipOptOut && {DEEPGRAM_SPEECH_MIP_OPT_OUT: mipOptOut}),
|
||||
};
|
||||
}
|
||||
else if ('soniox' === vendor) {
|
||||
|
||||
5418
package-lock.json
generated
5418
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -27,14 +27,14 @@
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-auto-scaling": "^3.549.0",
|
||||
"@aws-sdk/client-sns": "^3.549.0",
|
||||
"@jambonz/db-helpers": "^0.9.17",
|
||||
"@jambonz/db-helpers": "^0.9.16",
|
||||
"@jambonz/http-health-check": "^0.0.1",
|
||||
"@jambonz/mw-registrar": "^0.2.7",
|
||||
"@jambonz/realtimedb-helpers": "^0.8.15",
|
||||
"@jambonz/speech-utils": "^0.2.24",
|
||||
"@jambonz/speech-utils": "^0.2.22",
|
||||
"@jambonz/stats-collector": "^0.1.10",
|
||||
"@jambonz/time-series": "^0.2.14",
|
||||
"@jambonz/verb-specifications": "^0.0.116",
|
||||
"@jambonz/verb-specifications": "^0.0.113",
|
||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||
"@opentelemetry/api": "^1.8.0",
|
||||
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
||||
@@ -49,7 +49,7 @@
|
||||
"debug": "^4.3.4",
|
||||
"deepcopy": "^2.1.0",
|
||||
"drachtio-fsmrf": "^4.1.2",
|
||||
"drachtio-srf": "^5.0.11",
|
||||
"drachtio-srf": "^5.0.5",
|
||||
"express": "^4.19.2",
|
||||
"express-validator": "^7.0.1",
|
||||
"moment": "^2.30.1",
|
||||
|
||||
Reference in New Issue
Block a user