diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index ce269fef..a1a4c36e 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -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; diff --git a/lib/tasks/transcribe.js b/lib/tasks/transcribe.js index 6f7ad915..d693edbb 100644 --- a/lib/tasks/transcribe.js +++ b/lib/tasks/transcribe.js @@ -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 { diff --git a/package-lock.json b/package-lock.json index d591dfb3..40018ec7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index d6024bcb..e0ec6d7d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/gather-tests.js b/test/gather-tests.js index 31eb9ba5..6c39acd7 100644 --- a/test/gather-tests.js +++ b/test/gather-tests.js @@ -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');