Compare commits

...

11 Commits

Author SHA1 Message Date
Dave Horton
ad722a55ee generate trace id before outdial so we can include it in custom header (#418)
* generate trace id before outdial so we can include it in custom header

* logging

* logging

* fix #420 race condition on rest outdial when ws is used

* revert unnecessary logging change
2023-08-08 13:00:34 -04:00
Hoan Luu Huu
82939214a2 update stats-collector version (#421) 2023-08-07 21:22:10 -04:00
Dave Horton
043a171f41 remove log message 2023-08-07 15:22:03 -04:00
Dave Horton
c8e9b34b53 fix typo that caused record to fail on rest calls 2023-08-07 14:46:51 -04:00
Hoan Luu Huu
d7dcdb1d0c Continuos ASR for transcribe (#398)
* asrTimeout

* fix jslint

* change log

* fix interrim
2023-08-03 09:49:44 -04:00
Dave Horton
fbd0782258 #388 - support custom speech vendor in transcribe verb (#414)
Co-authored-by: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com>
2023-08-02 19:06:31 -04:00
Fábio Gomes
38f9329b12 When recordings are enabled, disable bidirectional audio on jambonz-session-record (#415) 2023-08-02 14:21:59 -04:00
Dave Horton
d4bfdf0916 #412 - dont delay sending call status when stopping background listen (#413) 2023-08-02 12:50:13 -04:00
Dave Horton
9203deef0f fix bug in prev commit 2023-08-02 10:27:50 -04:00
Dave Horton
48b182c891 Fix/rest outdial failure session hangs (#411)
* fix #410

* on rest outdial failure, if remote end closed gracefully don't wait for a reconnection
2023-08-01 12:59:30 -04:00
Dave Horton
e8e987cb9d Fix/snake case customer data issue 406 (#409)
* revert recent change on silence trimming

* fix issue with incorrectly snake-casing customer data (#406)
2023-07-27 22:31:43 -04:00
11 changed files with 189 additions and 48 deletions

View File

@@ -47,6 +47,11 @@ router.post('/', async(req, res) => {
const application = req.body.application_sid ? await lookupAppBySid(req.body.application_sid) : null; const application = req.body.application_sid ? await lookupAppBySid(req.body.application_sid) : null;
const record_all_calls = account.record_all_calls || (application && application.record_all_calls); const record_all_calls = account.record_all_calls || (application && application.record_all_calls);
const recordOutputFormat = account.record_format || 'mp3'; const recordOutputFormat = account.record_format || 'mp3';
const rootSpan = new RootSpan('rest-call', {
callSid,
accountSid,
...(req.body?.application_sid && {'X-Application-Sid': req.body.application_sid})
});
opts.headers = { opts.headers = {
...opts.headers, ...opts.headers,
@@ -54,6 +59,7 @@ router.post('/', async(req, res) => {
'X-Jambonz-FS-UUID': srf.locals.fsUUID, 'X-Jambonz-FS-UUID': srf.locals.fsUUID,
'X-Call-Sid': callSid, 'X-Call-Sid': callSid,
'X-Account-Sid': accountSid, 'X-Account-Sid': accountSid,
'X-Trace-ID': rootSpan.traceId,
...(req.body?.application_sid && {'X-Application-Sid': req.body.application_sid}), ...(req.body?.application_sid && {'X-Application-Sid': req.body.application_sid}),
...(restDial.fromHost && {'X-Preferred-From-Host': restDial.fromHost}), ...(restDial.fromHost && {'X-Preferred-From-Host': restDial.fromHost}),
...(record_all_calls && {'X-Record-All-Calls': recordOutputFormat}) ...(record_all_calls && {'X-Record-All-Calls': recordOutputFormat})
@@ -194,7 +200,6 @@ router.post('/', async(req, res) => {
/* ok our outbound INVITE is in flight */ /* ok our outbound INVITE is in flight */
const tasks = [restDial]; const tasks = [restDial];
const rootSpan = new RootSpan('rest-call', inviteReq);
sipLogger = logger.child({ sipLogger = logger.child({
callSid, callSid,
callId: inviteReq.get('Call-ID'), callId: inviteReq.get('Call-ID'),
@@ -258,6 +263,7 @@ router.post('/', async(req, res) => {
sipStatus: err.status, sipStatus: err.status,
sipReason: err.reason sipReason: err.reason
}); });
cs.callGone = true;
} }
else { else {
if (cs) cs.emit('callStatusChange', { if (cs) cs.emit('callStatusChange', {

View File

@@ -796,23 +796,15 @@ class CallSession extends Emitter {
} }
} }
if (0 === this.tasks.length && this.requestor instanceof WsRequestor && !this.callGone) { if (0 === this.tasks.length &&
//let span; this.requestor instanceof WsRequestor &&
!this.requestor.closedGracefully &&
!this.callGone
) {
try { try {
//const {span} = this.rootSpan.startChildSpan('waiting for commands');
//const {reason, queue, command} = await this._awaitCommandsOrHangup();
/*
span.setAttributes({
'completion.reason': reason,
'async.request.queue': queue,
'async.request.command': command
});
span.end();
*/
await this._awaitCommandsOrHangup(); await this._awaitCommandsOrHangup();
if (this.callGone) break; if (this.callGone) break;
} catch (err) { } catch (err) {
//span.end();
this.logger.info(err, 'CallSession:exec - error waiting for new commands'); this.logger.info(err, 'CallSession:exec - error waiting for new commands');
break; break;
} }
@@ -1769,7 +1761,8 @@ class CallSession extends Emitter {
// nice, call is in progress, good time to enable record // nice, call is in progress, good time to enable record
await this.enableRecordAllCall(); await this.enableRecordAllCall();
} else if (callStatus == CallStatus.Completed && this.isBackGroundListen) { } else if (callStatus == CallStatus.Completed && this.isBackGroundListen) {
await this.stopBackgroundListen(); this.stopBackgroundListen().catch((err) => this.logger.error(
{err}, 'CallSession:_notifyCallStatusChange - error stopping background listen'));
} }
/* race condition: we hang up at the same time as the caller */ /* race condition: we hang up at the same time as the caller */
@@ -1814,6 +1807,7 @@ class CallSession extends Emitter {
username: JAMBONZ_RECORD_WS_USERNAME, username: JAMBONZ_RECORD_WS_USERNAME,
password: JAMBONZ_RECORD_WS_PASSWORD password: JAMBONZ_RECORD_WS_PASSWORD
}, },
disableBidirectionalAudio: true,
mixType : 'stereo', mixType : 'stereo',
passDtmf: true passDtmf: true
}; };

View File

@@ -49,7 +49,6 @@ class RestCallSession extends CallSession {
*/ */
_callerHungup() { _callerHungup() {
if (this.restDialTask) { if (this.restDialTask) {
this.logger.info('RestCallSession: releasing AMD');
this.restDialTask.turnOffAmd(); this.restDialTask.turnOffAmd();
} }
this.callInfo.callTerminationBy = 'caller'; this.callInfo.callTerminationBy = 'caller';

View File

@@ -8,6 +8,7 @@ const DTMF_SPAN_NAME = 'dtmf';
class TaskListen extends Task { class TaskListen extends Task {
constructor(logger, opts, parentTask) { constructor(logger, opts, parentTask) {
super(logger, opts); super(logger, opts);
this.disableBidirectionalAudio = opts.disableBidirectionalAudio;
this.preconditions = TaskPreconditions.Endpoint; this.preconditions = TaskPreconditions.Endpoint;
[ [
@@ -154,7 +155,7 @@ class TaskListen extends Task {
} }
/* support bi-directional audio */ /* support bi-directional audio */
if (!this.disableBiDirectionalAudio) { if (!this.disableBidirectionalAudio) {
ep.addCustomEventListener(ListenEvents.PlayAudio, this._onPlayAudio.bind(this, ep)); ep.addCustomEventListener(ListenEvents.PlayAudio, this._onPlayAudio.bind(this, ep));
} }
ep.addCustomEventListener(ListenEvents.KillAudio, this._onKillAudio.bind(this, ep)); ep.addCustomEventListener(ListenEvents.KillAudio, this._onKillAudio.bind(this, ep));

View File

@@ -63,12 +63,13 @@ class TaskRestDial extends Task {
this.canCancel = false; this.canCancel = false;
const cs = this.callSession; const cs = this.callSession;
cs.setDialog(dlg); cs.setDialog(dlg);
this.logger.debug('TaskRestDial:_onConnect - call connected');
try { try {
const b3 = this.getTracingPropagation(); const b3 = this.getTracingPropagation();
const httpHeaders = b3 && {b3}; const httpHeaders = b3 && {b3};
const params = { const params = {
...cs.callInfo, ...(cs.callInfo.toJSON()),
defaults: { defaults: {
synthesizer: { synthesizer: {
vendor: cs.speechSynthesisVendor, vendor: cs.speechSynthesisVendor,
@@ -90,8 +91,10 @@ class TaskRestDial extends Task {
} }
let tasks; let tasks;
if (this.app_json) { if (this.app_json) {
this.logger.debug('TaskRestDial: using app_json from task data');
tasks = JSON.parse(this.app_json); tasks = JSON.parse(this.app_json);
} else { } else {
this.logger.debug({call_hook: this.call_hook}, 'TaskRestDial: retrieving application');
tasks = await cs.requestor.request('session:new', this.call_hook, params, httpHeaders); tasks = await cs.requestor.request('session:new', this.call_hook, params, httpHeaders);
} }
if (tasks && Array.isArray(tasks)) { if (tasks && Array.isArray(tasks)) {

View File

@@ -1,4 +1,5 @@
const Task = require('./task'); const Task = require('./task');
const assert = require('assert');
const { const {
TaskName, TaskName,
TaskPreconditions, TaskPreconditions,
@@ -56,6 +57,12 @@ class TaskTranscribe extends Task {
this._sonioxTranscripts = []; this._sonioxTranscripts = [];
this.childSpan = [null, null]; this.childSpan = [null, null];
// Continuos asr timeout
this.asrTimeout = typeof this.data.recognizer.asrTimeout === 'number' ? this.data.recognizer.asrTimeout * 1000 : 0;
this.isContinuousAsr = this.asrTimeout > 0;
/* buffer speech for continuous asr */
this._bufferedTranscripts = [];
} }
get name() { return TaskName.Transcribe; } get name() { return TaskName.Transcribe; }
@@ -234,7 +241,19 @@ class TaskTranscribe extends Task {
this._onVadDetected.bind(this, cs, ep)); this._onVadDetected.bind(this, cs, ep));
break; break;
default: default:
throw new Error(`Invalid vendor ${this.vendor}`); if (this.vendor.startsWith('custom:')) {
this.bugname = `${this.vendor}_transcribe`;
ep.addCustomEventListener(JambonzTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep));
ep.addCustomEventListener(JambonzTranscriptionEvents.Connect, this._onJambonzConnect.bind(this, cs, ep));
ep.addCustomEventListener(JambonzTranscriptionEvents.ConnectFailure,
this._onJambonzConnectFailure.bind(this, cs, ep));
break;
}
else {
this.notifyError({ msg: 'ASR error', details:`Invalid vendor ${this.vendor}`});
this.notifyTaskDone();
throw new Error(`Invalid vendor ${this.vendor}`);
}
} }
/* common handler for all stt engine errors */ /* common handler for all stt engine errors */
@@ -296,6 +315,26 @@ class TaskTranscribe extends Task {
} }
} }
if (this.isContinuousAsr && evt.is_final) {
this._bufferedTranscripts.push(evt);
this._startAsrTimer(channel);
} else {
await this._resolve(channel, evt);
}
}
_compileTranscripts() {
assert(this._bufferedTranscripts.length);
const evt = this._bufferedTranscripts[0];
let t = '';
for (const a of this._bufferedTranscripts) {
t += ` ${a.alternatives[0].transcript}`;
}
evt.alternatives[0].transcript = t.trim();
return evt;
}
async _resolve(channel, evt) {
/* we've got a transcript, so end the otel child span for this channel */ /* we've got a transcript, so end the otel child span for this channel */
if (this.childSpan[channel - 1] && this.childSpan[channel - 1].span) { if (this.childSpan[channel - 1] && this.childSpan[channel - 1].span) {
this.childSpan[channel - 1].span.setAttributes({ this.childSpan[channel - 1].span.setAttributes({
@@ -408,6 +447,24 @@ class TaskTranscribe extends Task {
this.notifyTaskDone(); this.notifyTaskDone();
} }
_onJambonzConnect(_cs, _ep) {
this.logger.debug('TaskTranscribe:_onJambonzConnect');
}
_onJambonzConnectFailure(cs, _ep, evt) {
const {reason} = evt;
const {writeAlerts, AlertType} = cs.srf.locals;
this.logger.info({evt}, 'TaskTranscribe:_onJambonzConnectFailure');
writeAlerts({
account_sid: cs.accountSid,
alert_type: AlertType.STT_FAILURE,
message: `Failed connecting to ${this.vendor} speech recognizer: ${reason}`,
vendor: this.vendor,
}).catch((err) => this.logger.info({err}, 'Error generating alert for jambonz custom connection failure'));
this.notifyError({msg: 'ASR error', details:`Failed connecting to speech vendor ${this.vendor}: ${reason}`});
this.notifyTaskDone();
}
_onIbmConnect(_cs, _ep) { _onIbmConnect(_cs, _ep) {
this.logger.debug('TaskTranscribe:_onIbmConnect'); this.logger.debug('TaskTranscribe:_onIbmConnect');
} }
@@ -455,7 +512,22 @@ class TaskTranscribe extends Task {
this.notifyError({msg: 'ASR error', details:`Custom speech vendor ${this.vendor} error: ${evt.error}`}); this.notifyError({msg: 'ASR error', details:`Custom speech vendor ${this.vendor} error: ${evt.error}`});
} }
_startAsrTimer(channel) {
assert(this.isContinuousAsr);
this._clearAsrTimer(channel);
this._asrTimer = setTimeout(() => {
this.logger.debug(`TaskTranscribe:_startAsrTimer - asr timer went off for channel: ${channel}`);
const evt = this._compileTranscripts();
this._bufferedTranscripts = [];
this._resolve(channel, evt);
}, this.asrTimeout);
this.logger.debug(`TaskTranscribe:_startAsrTimer: set for ${this.asrTimeout}ms for channel ${channel}`);
}
_clearAsrTimer(channel) {
if (this._asrTimer) clearTimeout(this._asrTimer);
this._asrTimer = null;
}
} }
module.exports = TaskTranscribe; module.exports = TaskTranscribe;

View File

@@ -2,17 +2,24 @@ const {context, trace} = require('@opentelemetry/api');
const {Dialog} = require('drachtio-srf'); const {Dialog} = require('drachtio-srf');
class RootSpan { class RootSpan {
constructor(callType, req) { constructor(callType, req) {
let tracer, callSid, linkedSpanId; const {srf} = require('../../');
const tracer = srf.locals.otel.tracer;
let callSid, accountSid, applicationSid, linkedSpanId;
if (req instanceof Dialog) { if (req instanceof Dialog) {
const dlg = req; const dlg = req;
tracer = dlg.srf.locals.otel.tracer;
callSid = dlg.callSid; callSid = dlg.callSid;
linkedSpanId = dlg.linkedSpanId; linkedSpanId = dlg.linkedSpanId;
} }
else { else if (req.srf) {
tracer = req.srf.locals.otel.tracer;
callSid = req.locals.callSid; callSid = req.locals.callSid;
accountSid = req.get('X-Account-Sid'),
applicationSid = req.locals.application_sid;
}
else {
callSid = req.callSid;
accountSid = req.accountSid;
applicationSid = req.applicationSid;
} }
this._span = tracer.startSpan(callType || 'incoming-call'); this._span = tracer.startSpan(callType || 'incoming-call');
if (req instanceof Dialog) { if (req instanceof Dialog) {
@@ -22,13 +29,20 @@ class RootSpan {
callId: dlg.sip.callId callId: dlg.sip.callId
}); });
} }
else if (req.srf) {
this._span.setAttributes({
callSid,
accountSid,
applicationSid,
callId: req.get('Call-ID'),
externalCallId: req.get('X-CID')
});
}
else { else {
this._span.setAttributes({ this._span.setAttributes({
callSid, callSid,
accountSid: req.get('X-Account-Sid'), accountSid,
applicationSid: req.locals.application_sid, applicationSid
callId: req.get('Call-ID'),
externalCallId: req.get('X-CID')
}); });
} }

View File

@@ -43,6 +43,7 @@ class WsRequestor extends BaseRequestor {
async request(type, hook, params, httpHeaders = {}) { async request(type, hook, params, httpHeaders = {}) {
assert(HookMsgTypes.includes(type)); assert(HookMsgTypes.includes(type));
const url = hook.url || hook; const url = hook.url || hook;
const wantsAck = !['call:status', 'verb:status', 'jambonz:error'].includes(type);
if (this.maliciousClient) { if (this.maliciousClient) {
this.logger.info({url: this.url}, 'WsRequestor:request - discarding msg to malicious client'); this.logger.info({url: this.url}, 'WsRequestor:request - discarding msg to malicious client');
@@ -73,11 +74,19 @@ class WsRequestor extends BaseRequestor {
if (this.connectInProgress) { if (this.connectInProgress) {
this.logger.debug( this.logger.debug(
`WsRequestor:request(${this.id}) - queueing ${type} message since we are connecting`); `WsRequestor:request(${this.id}) - queueing ${type} message since we are connecting`);
this.queuedMsg.push({type, hook, params, httpHeaders}); if (wantsAck) {
const p = new Promise((resolve, reject) => {
this.queuedMsg.push({type, hook, params, httpHeaders, promise: {resolve, reject}});
});
return p;
}
else {
this.queuedMsg.push({type, hook, params, httpHeaders});
}
return; return;
} }
this.connectInProgress = true; this.connectInProgress = true;
this.logger.debug(`WsRequestor:request(${this.id}) - connecting since we do not have a connection`); this.logger.debug(`WsRequestor:request(${this.id}) - connecting since we do not have a connection for ${type}`);
if (this.connections >= MAX_RECONNECTS) { if (this.connections >= MAX_RECONNECTS) {
return Promise.reject(`max attempts connecting to ${this.url}`); return Promise.reject(`max attempts connecting to ${this.url}`);
} }
@@ -116,9 +125,14 @@ class WsRequestor extends BaseRequestor {
const sendQueuedMsgs = () => { const sendQueuedMsgs = () => {
if (this.queuedMsg.length > 0) { if (this.queuedMsg.length > 0) {
for (const {type, hook, params, httpHeaders} of this.queuedMsg) { for (const {type, hook, params, httpHeaders, promise} of this.queuedMsg) {
this.logger.debug(`WsRequestor:request - preparing queued ${type} for sending`); this.logger.debug(`WsRequestor:request - preparing queued ${type} for sending`);
setImmediate(this.request.bind(this, type, hook, params, httpHeaders)); if (promise) {
this.request(type, hook, params, httpHeaders)
.then((res) => promise.resolve(res))
.catch((err) => promise.reject(err));
}
else setImmediate(this.request.bind(this, type, hook, params, httpHeaders));
} }
this.queuedMsg.length = 0; this.queuedMsg.length = 0;
} }
@@ -137,7 +151,7 @@ class WsRequestor extends BaseRequestor {
} }
/* simple notifications */ /* simple notifications */
if (['call:status', 'verb:status', 'jambonz:error'].includes(type) || reconnectingWithoutAck) { if (!wantsAck || reconnectingWithoutAck) {
this.ws?.send(JSON.stringify(obj), () => { this.ws?.send(JSON.stringify(obj), () => {
this.logger.debug({obj}, `WsRequestor:request websocket: sent (${url})`); this.logger.debug({obj}, `WsRequestor:request websocket: sent (${url})`);
sendQueuedMsgs(); sendQueuedMsgs();

28
package-lock.json generated
View File

@@ -14,8 +14,8 @@
"@jambonz/db-helpers": "^0.9.1", "@jambonz/db-helpers": "^0.9.1",
"@jambonz/http-health-check": "^0.0.1", "@jambonz/http-health-check": "^0.0.1",
"@jambonz/realtimedb-helpers": "^0.8.6", "@jambonz/realtimedb-helpers": "^0.8.6",
"@jambonz/speech-utils": "^0.0.18", "@jambonz/speech-utils": "^0.0.19",
"@jambonz/stats-collector": "^0.1.8", "@jambonz/stats-collector": "^0.1.9",
"@jambonz/time-series": "^0.2.8", "@jambonz/time-series": "^0.2.8",
"@jambonz/verb-specifications": "^0.0.26", "@jambonz/verb-specifications": "^0.0.26",
"@opentelemetry/api": "^1.4.0", "@opentelemetry/api": "^1.4.0",
@@ -2983,9 +2983,9 @@
} }
}, },
"node_modules/@jambonz/speech-utils": { "node_modules/@jambonz/speech-utils": {
"version": "0.0.18", "version": "0.0.19",
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.18.tgz", "resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.19.tgz",
"integrity": "sha512-UoX1sPV/kDUBp4uiivbFftpn9nx6G9rmspneszrksnSWERp0SP09yL6rvEFFTDMvFmK2ivP6TIMRywlExO4OQg==", "integrity": "sha512-uVwt4cCQkNhRDDPK0BHgI9Zn+bXoqQdtK8kjj3dbqPAOO3FlMTWxA2ZWJoglzZShQUNzpEg3CLcVTAGNnJHP2Q==",
"dependencies": { "dependencies": {
"@aws-sdk/client-polly": "^3.359.0", "@aws-sdk/client-polly": "^3.359.0",
"@google-cloud/text-to-speech": "^4.2.1", "@google-cloud/text-to-speech": "^4.2.1",
@@ -3001,9 +3001,9 @@
} }
}, },
"node_modules/@jambonz/stats-collector": { "node_modules/@jambonz/stats-collector": {
"version": "0.1.8", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@jambonz/stats-collector/-/stats-collector-0.1.8.tgz", "resolved": "https://registry.npmjs.org/@jambonz/stats-collector/-/stats-collector-0.1.9.tgz",
"integrity": "sha512-PadBKTmcphU7bZI7pVr4awhoIi+DMLw7An6AGE0GGsLCn2x0IGnxr9k47gI4Bk3OaSF6N7RyVLEAMkJfr24l8Q==", "integrity": "sha512-JNRBaHQ47pWsXydj4gUp7zc64/0pM89a6E9pA8uQ15l1KxPGYYTrNRdone5aJqLTFOoPl3tYeF1kXj+3nU1nEA==",
"dependencies": { "dependencies": {
"debug": "^4.3.2", "debug": "^4.3.2",
"hot-shots": "^8.5.0" "hot-shots": "^8.5.0"
@@ -12949,9 +12949,9 @@
} }
}, },
"@jambonz/speech-utils": { "@jambonz/speech-utils": {
"version": "0.0.18", "version": "0.0.19",
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.18.tgz", "resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.19.tgz",
"integrity": "sha512-UoX1sPV/kDUBp4uiivbFftpn9nx6G9rmspneszrksnSWERp0SP09yL6rvEFFTDMvFmK2ivP6TIMRywlExO4OQg==", "integrity": "sha512-uVwt4cCQkNhRDDPK0BHgI9Zn+bXoqQdtK8kjj3dbqPAOO3FlMTWxA2ZWJoglzZShQUNzpEg3CLcVTAGNnJHP2Q==",
"requires": { "requires": {
"@aws-sdk/client-polly": "^3.359.0", "@aws-sdk/client-polly": "^3.359.0",
"@google-cloud/text-to-speech": "^4.2.1", "@google-cloud/text-to-speech": "^4.2.1",
@@ -12967,9 +12967,9 @@
} }
}, },
"@jambonz/stats-collector": { "@jambonz/stats-collector": {
"version": "0.1.8", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@jambonz/stats-collector/-/stats-collector-0.1.8.tgz", "resolved": "https://registry.npmjs.org/@jambonz/stats-collector/-/stats-collector-0.1.9.tgz",
"integrity": "sha512-PadBKTmcphU7bZI7pVr4awhoIi+DMLw7An6AGE0GGsLCn2x0IGnxr9k47gI4Bk3OaSF6N7RyVLEAMkJfr24l8Q==", "integrity": "sha512-JNRBaHQ47pWsXydj4gUp7zc64/0pM89a6E9pA8uQ15l1KxPGYYTrNRdone5aJqLTFOoPl3tYeF1kXj+3nU1nEA==",
"requires": { "requires": {
"debug": "^4.3.2", "debug": "^4.3.2",
"hot-shots": "^8.5.0" "hot-shots": "^8.5.0"

View File

@@ -28,8 +28,8 @@
"@jambonz/db-helpers": "^0.9.1", "@jambonz/db-helpers": "^0.9.1",
"@jambonz/http-health-check": "^0.0.1", "@jambonz/http-health-check": "^0.0.1",
"@jambonz/realtimedb-helpers": "^0.8.6", "@jambonz/realtimedb-helpers": "^0.8.6",
"@jambonz/speech-utils": "^0.0.18", "@jambonz/speech-utils": "^0.0.19",
"@jambonz/stats-collector": "^0.1.8", "@jambonz/stats-collector": "^0.1.9",
"@jambonz/time-series": "^0.2.8", "@jambonz/time-series": "^0.2.8",
"@jambonz/verb-specifications": "^0.0.26", "@jambonz/verb-specifications": "^0.0.26",
"@opentelemetry/api": "^1.4.0", "@opentelemetry/api": "^1.4.0",

View File

@@ -210,6 +210,44 @@ test('\'transcribe\' test - soniox', async(t) => {
t.ok(obj.body.speech.alternatives[0].transcript.toLowerCase().startsWith('i\'d like to speak to customer support'), t.ok(obj.body.speech.alternatives[0].transcript.toLowerCase().startsWith('i\'d like to speak to customer support'),
'transcribe: succeeds when using soniox credentials'); 'transcribe: succeeds when using soniox credentials');
disconnect();
} catch (err) {
console.log(`error received: ${err}`);
disconnect();
t.error(err);
}
});
test('\'transcribe\' test - google with asrTimeout', async(t) => {
if (!GCP_JSON_KEY) {
t.pass('skipping google tests');
return t.end();
}
clearModule.all();
const {srf, disconnect} = require('../app');
try {
await connect(srf);
// GIVEN
let verbs = [
{
"verb": "transcribe",
"recognizer": {
"vendor": "google",
"hints": ["customer support", "sales", "human resources", "HR"],
"asrTimeout": 4
},
"transcriptionHook": "/transcriptionHook"
}
];
let from = "gather_success";
await provisionCallHook(from, verbs);
// THEN
await sippUac('uac-gather-account-creds-success.xml', '172.38.0.10', from);
let obj = await getJSON(`http://127.0.0.1:3100/lastRequest/${from}_actionHook`);
t.ok(obj.body.speech.alternatives[0].transcript.toLowerCase().startsWith('i\'d like to speak to customer support'),
'transcribe: succeeds when using google credentials');
disconnect(); disconnect();
} catch (err) { } catch (err) {
console.log(`error received: ${err}`); console.log(`error received: ${err}`);