bugfix: handle gather/transcribe where vendor not explicitly specified #187

This commit is contained in:
Dave Horton
2022-11-07 09:31:51 -05:00
parent e5c209e269
commit 706cd4b94b
5 changed files with 49 additions and 9 deletions

View File

@@ -145,7 +145,9 @@ class TaskGather extends Task {
this.ep = ep;
if ('default' === this.vendor || !this.vendor) this.vendor = cs.speechRecognizerVendor;
if ('default' === this.language || !this.language) this.language = cs.speechRecognizerLanguage;
if (!this.data.recognizer.vendor) {
this.data.recognizer.vendor = this.vendor;
}
if (this.needsStt && !this.sttCredentials) this.sttCredentials = cs.getSpeechCredentials(this.vendor, 'stt');
if (this.needsStt && !this.sttCredentials) {
const {writeAlerts, AlertType} = cs.srf.locals;

View File

@@ -66,6 +66,9 @@ class TaskTranscribe extends Task {
this.ep2 = ep2;
if ('default' === this.vendor || !this.vendor) this.vendor = cs.speechRecognizerVendor;
if ('default' === this.language || !this.language) this.language = cs.speechRecognizerLanguage;
if (!this.data.recognizer.vendor) {
this.data.recognizer.vendor = this.vendor;
}
this.sttCredentials = cs.getSpeechCredentials(this.vendor, 'stt');
try {

14
package-lock.json generated
View File

@@ -11,7 +11,7 @@
"dependencies": {
"@jambonz/db-helpers": "^0.7.3",
"@jambonz/http-health-check": "^0.0.1",
"@jambonz/realtimedb-helpers": "^0.5.5",
"@jambonz/realtimedb-helpers": "^0.5.7",
"@jambonz/stats-collector": "^0.1.6",
"@jambonz/time-series": "^0.2.5",
"@opentelemetry/api": "^1.2.0",
@@ -543,9 +543,9 @@
}
},
"node_modules/@jambonz/realtimedb-helpers": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.5.5.tgz",
"integrity": "sha512-tQJfTqN1FtFfKR9ceBYuQ9yddCDshBGVI6v1N/IxOyhTywyueNFXg6JMIOx0Rci7UqIDhtcBjl5R64zWgTo04A==",
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.5.7.tgz",
"integrity": "sha512-TOTnFWSa4ronCdQTWfB8c5VI6DXcBEyDA4vbZnzkVAzSP90NpRPOPrvo2tEZxcGSlVIjBZew7rWgWyqkSwUT/Q==",
"dependencies": {
"@google-cloud/text-to-speech": "^4.0.3",
"@grpc/grpc-js": "^1.7.3",
@@ -6888,9 +6888,9 @@
}
},
"@jambonz/realtimedb-helpers": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.5.5.tgz",
"integrity": "sha512-tQJfTqN1FtFfKR9ceBYuQ9yddCDshBGVI6v1N/IxOyhTywyueNFXg6JMIOx0Rci7UqIDhtcBjl5R64zWgTo04A==",
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.5.7.tgz",
"integrity": "sha512-TOTnFWSa4ronCdQTWfB8c5VI6DXcBEyDA4vbZnzkVAzSP90NpRPOPrvo2tEZxcGSlVIjBZew7rWgWyqkSwUT/Q==",
"requires": {
"@google-cloud/text-to-speech": "^4.0.3",
"@grpc/grpc-js": "^1.7.3",

View File

@@ -25,8 +25,8 @@
},
"dependencies": {
"@jambonz/db-helpers": "^0.7.3",
"@jambonz/realtimedb-helpers": "^0.5.5",
"@jambonz/http-health-check": "^0.0.1",
"@jambonz/realtimedb-helpers": "^0.5.7",
"@jambonz/stats-collector": "^0.1.6",
"@jambonz/time-series": "^0.2.5",
"@opentelemetry/api": "^1.2.0",

View File

@@ -56,6 +56,41 @@ test('\'gather\' test - google', async(t) => {
}
});
test('\'gather\' test - default (google)', async(t) => {
if (!process.env.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": "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`);
t.ok(obj.body.speech.alternatives[0].transcript = 'I\'d like to speak to customer support',
'gather: succeeds when using default (google) credentials');
disconnect();
} catch (err) {
console.log(`error received: ${err}`);
disconnect();
t.error(err);
}
});
test('\'gather\' test - microsoft', async(t) => {
if (!process.env.MICROSOFT_REGION || !process.env.MICROSOFT_API_KEY) {
t.pass('skipping microsoft tests');