mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-22 01:27:55 +00:00
@@ -64,6 +64,16 @@ class CallSession extends Emitter {
|
|||||||
this.notifiedComplete = false;
|
this.notifiedComplete = false;
|
||||||
this.rootSpan = rootSpan;
|
this.rootSpan = rootSpan;
|
||||||
|
|
||||||
|
this._origRecognizerSettings = {
|
||||||
|
vendor: this.application?.speech_recognizer_vendor,
|
||||||
|
language: this.application?.speech_recognizer_language,
|
||||||
|
};
|
||||||
|
this._origSynthesizerSettings = {
|
||||||
|
vendor: this.application?.speech_synthesis_vendor,
|
||||||
|
language: this.application?.speech_synthesis_language,
|
||||||
|
voice: this.application?.speech_synthesis_voice,
|
||||||
|
};
|
||||||
|
|
||||||
assert(rootSpan);
|
assert(rootSpan);
|
||||||
|
|
||||||
this._recordState = RecordState.RecordingOff;
|
this._recordState = RecordState.RecordingOff;
|
||||||
@@ -324,6 +334,22 @@ class CallSession extends Emitter {
|
|||||||
return this._globalSttPunctuation !== undefined;
|
return this._globalSttPunctuation !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetRecognizer() {
|
||||||
|
this._globalSttHints = undefined;
|
||||||
|
this._globalSttPunctuation = undefined;
|
||||||
|
this._globalAltLanguages = undefined;
|
||||||
|
this.isContinuousAsr = false;
|
||||||
|
this.asrDtmfTerminationDigits = undefined;
|
||||||
|
this.speechRecognizerLanguage = this._origRecognizerSettings.language;
|
||||||
|
this.speechRecognizerVendor = this._origRecognizerSettings.vendor;
|
||||||
|
}
|
||||||
|
|
||||||
|
resetSynthesizer() {
|
||||||
|
this.speechSynthesisLanguage = this._origSynthesizerSettings.language;
|
||||||
|
this.speechSynthesisVendor = this._origSynthesizerSettings.vendor;
|
||||||
|
this.speechSynthesisVoice = this._origSynthesizerSettings.voice;
|
||||||
|
}
|
||||||
|
|
||||||
async notifyRecordOptions(opts) {
|
async notifyRecordOptions(opts) {
|
||||||
const {action} = opts;
|
const {action} = opts;
|
||||||
this.logger.debug({opts}, 'CallSession:notifyRecordOptions');
|
this.logger.debug({opts}, 'CallSession:notifyRecordOptions');
|
||||||
@@ -680,6 +706,12 @@ class CallSession extends Emitter {
|
|||||||
stt_region: credential.stt_region
|
stt_region: credential.stt_region
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
else if ('nvidia' === vendor) {
|
||||||
|
return {
|
||||||
|
speech_credential_sid: credential.speech_credential_sid,
|
||||||
|
riva_server_uri: credential.riva_server_uri
|
||||||
|
};
|
||||||
|
}
|
||||||
else if (vendor.startsWith('custom:')) {
|
else if (vendor.startsWith('custom:')) {
|
||||||
return {
|
return {
|
||||||
speech_credential_sid: credential.speech_credential_sid,
|
speech_credential_sid: credential.speech_credential_sid,
|
||||||
|
|||||||
@@ -45,6 +45,14 @@ class TaskConfig extends Task {
|
|||||||
|
|
||||||
get summary() {
|
get summary() {
|
||||||
const phrase = [];
|
const phrase = [];
|
||||||
|
|
||||||
|
/* reset recognizer and/or synthesizer to default values? */
|
||||||
|
if (this.data.reset) {
|
||||||
|
if (typeof this.data.reset === 'string') this.data.reset = [this.data.reset];
|
||||||
|
phrase.push(`reset ${this.data.reset.join(',')}`);
|
||||||
|
}
|
||||||
|
else this.data.reset = [];
|
||||||
|
|
||||||
if (this.bargeIn.enable) phrase.push('enable barge-in');
|
if (this.bargeIn.enable) phrase.push('enable barge-in');
|
||||||
if (this.hasSynthesizer) {
|
if (this.hasSynthesizer) {
|
||||||
const {vendor:v, language:l, voice} = this.synthesizer;
|
const {vendor:v, language:l, voice} = this.synthesizer;
|
||||||
@@ -86,6 +94,11 @@ class TaskConfig extends Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.data.reset.forEach((k) => {
|
||||||
|
if (k === 'synthesizer') cs.resetSynthesizer();
|
||||||
|
else if (k === 'recognizer') cs.resetRecognizer();
|
||||||
|
});
|
||||||
|
|
||||||
if (this.hasSynthesizer) {
|
if (this.hasSynthesizer) {
|
||||||
cs.speechSynthesisVendor = this.synthesizer.vendor !== 'default'
|
cs.speechSynthesisVendor = this.synthesizer.vendor !== 'default'
|
||||||
? this.synthesizer.vendor
|
? this.synthesizer.vendor
|
||||||
|
|||||||
@@ -78,6 +78,10 @@ const speechMapper = (cred) => {
|
|||||||
const o = JSON.parse(decrypt(credential));
|
const o = JSON.parse(decrypt(credential));
|
||||||
obj.api_key = o.api_key;
|
obj.api_key = o.api_key;
|
||||||
}
|
}
|
||||||
|
else if ('nvidia' === obj.vendor) {
|
||||||
|
const o = JSON.parse(decrypt(credential));
|
||||||
|
obj.riva_server_uri = o.riva_server_uri;
|
||||||
|
}
|
||||||
else if (obj.vendor.startsWith('custom:')) {
|
else if (obj.vendor.startsWith('custom:')) {
|
||||||
const o = JSON.parse(decrypt(credential));
|
const o = JSON.parse(decrypt(credential));
|
||||||
obj.auth_token = o.auth_token;
|
obj.auth_token = o.auth_token;
|
||||||
|
|||||||
4502
package-lock.json
generated
4502
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -25,13 +25,13 @@
|
|||||||
"jslint:fix": "eslint app.js tracer.js lib --fix"
|
"jslint:fix": "eslint app.js tracer.js lib --fix"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jambonz/db-helpers": "^0.7.4",
|
"@jambonz/db-helpers": "^0.7.9",
|
||||||
"@jambonz/http-health-check": "^0.0.1",
|
"@jambonz/http-health-check": "^0.0.1",
|
||||||
"@jambonz/realtimedb-helpers": "^0.7.0",
|
"@jambonz/realtimedb-helpers": "^0.7.2",
|
||||||
"@jambonz/speech-utils": "^0.0.12",
|
"@jambonz/speech-utils": "^0.0.12",
|
||||||
"@jambonz/stats-collector": "^0.1.8",
|
"@jambonz/stats-collector": "^0.1.8",
|
||||||
"@jambonz/time-series": "^0.2.5",
|
"@jambonz/time-series": "^0.2.5",
|
||||||
"@jambonz/verb-specifications": "^0.0.17",
|
"@jambonz/verb-specifications": "^0.0.21",
|
||||||
"@opentelemetry/api": "^1.4.0",
|
"@opentelemetry/api": "^1.4.0",
|
||||||
"@opentelemetry/exporter-jaeger": "^1.9.0",
|
"@opentelemetry/exporter-jaeger": "^1.9.0",
|
||||||
"@opentelemetry/exporter-trace-otlp-http": "^0.35.0",
|
"@opentelemetry/exporter-trace-otlp-http": "^0.35.0",
|
||||||
|
|||||||
@@ -102,6 +102,53 @@ test('\'gather\' test - default (google)', async(t) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('\'config\' test - reset to app defaults', async(t) => {
|
||||||
|
if (!GCP_JSON_KEY) {
|
||||||
|
t.pass('skipping config tests');
|
||||||
|
return t.end();
|
||||||
|
}
|
||||||
|
clearModule.all();
|
||||||
|
const {srf, disconnect} = require('../app');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await connect(srf);
|
||||||
|
// GIVEN
|
||||||
|
let verbs = [
|
||||||
|
{
|
||||||
|
"verb": "config",
|
||||||
|
"recognizer": {
|
||||||
|
"vendor": "google",
|
||||||
|
"language": "fr-FR"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "config",
|
||||||
|
"reset": ['recognizer'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "gather",
|
||||||
|
"input": ["speech"],
|
||||||
|
"timeout": 10,
|
||||||
|
"actionHook": "/actionHook"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
let from = "gather_success";
|
||||||
|
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`);
|
||||||
|
//console.log(JSON.stringify(obj));
|
||||||
|
t.ok(obj.body.speech.alternatives[0].transcript.toLowerCase() === 'i\'d like to speak to customer support',
|
||||||
|
'config: resets recognizer to app defaults');
|
||||||
|
|
||||||
|
disconnect();
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`error received: ${err}`);
|
||||||
|
disconnect();
|
||||||
|
t.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('\'gather\' test - microsoft', async(t) => {
|
test('\'gather\' test - microsoft', async(t) => {
|
||||||
if (!MICROSOFT_REGION || !MICROSOFT_API_KEY) {
|
if (!MICROSOFT_REGION || !MICROSOFT_API_KEY) {
|
||||||
t.pass('skipping microsoft tests');
|
t.pass('skipping microsoft tests');
|
||||||
|
|||||||
@@ -43,3 +43,43 @@ test('\'say\' tests', async(t) => {
|
|||||||
t.error(err);
|
t.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('\'config\' reset synthesizer tests', async(t) => {
|
||||||
|
clearModule.all();
|
||||||
|
const {srf, disconnect} = require('../app');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await connect(srf);
|
||||||
|
|
||||||
|
// GIVEN
|
||||||
|
const verbs = [
|
||||||
|
{
|
||||||
|
"verb": "config",
|
||||||
|
"synthesizer": {
|
||||||
|
"vendor": "microsft",
|
||||||
|
"voice": "foobar"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "config",
|
||||||
|
"reset": 'synthesizer',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
verb: 'say',
|
||||||
|
text: 'hello'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const from = 'say_test_success';
|
||||||
|
provisionCallHook(from, verbs)
|
||||||
|
|
||||||
|
// THEN
|
||||||
|
await sippUac('uac-success-received-bye.xml', '172.38.0.10', from);
|
||||||
|
t.pass('say: succeeds when using using account credentials');
|
||||||
|
disconnect();
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`error received: ${err}`);
|
||||||
|
disconnect();
|
||||||
|
t.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user