From 39fb762a156bfbf16910d8a5483721e72041bb71 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Sun, 4 Dec 2022 11:26:26 -0500 Subject: [PATCH] ibm speech fix --- lib/session/call-session.js | 5 ++++- lib/tasks/say.js | 2 +- lib/utils/db-utils.js | 12 ++++++++++++ package-lock.json | 30 +++++++++++++++--------------- package.json | 2 +- 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 564deb41..82338a88 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -578,7 +578,10 @@ class CallSession extends Emitter { else if ('ibm' === vendor) { return { speech_credential_sid: credential.speech_credential_sid, - api_key: credential.api_key + tts_api_key: credential.tts_api_key, + tts_region: credential.tts_region, + stt_api_key: credential.stt_api_key, + stt_region: credential.stt_region }; } } diff --git a/lib/tasks/say.js b/lib/tasks/say.js index 2b1d59ba..a2b5c061 100644 --- a/lib/tasks/say.js +++ b/lib/tasks/say.js @@ -137,7 +137,7 @@ class TaskSay extends Task { const salt = cs.callSid; const credentials = cs.getSpeechCredentials(vendor, 'tts'); - /* parse Nuance voces into name and model */ + /* parse Nuance voices into name and model */ let model; if (vendor === 'nuance' && voice) { const arr = /([A-Za-z-]*)\s+-\s+(enhanced|standard)/.exec(voice); diff --git a/lib/utils/db-utils.js b/lib/utils/db-utils.js index e081c627..49a05f14 100644 --- a/lib/utils/db-utils.js +++ b/lib/utils/db-utils.js @@ -51,6 +51,13 @@ const speechMapper = (cred) => { obj.client_id = o.client_id; obj.secret = o.secret; } + else if ('ibm' === obj.vendor) { + const o = JSON.parse(decrypt(credential)); + obj.tts_api_key = o.tts_api_key; + obj.tts_region = o.tts_region; + obj.stt_api_key = o.stt_api_key; + obj.stt_region = o.stt_region; + } else if ('deepgram' === obj.vendor) { const o = JSON.parse(decrypt(credential)); obj.api_key = o.api_key; @@ -79,6 +86,7 @@ module.exports = (logger, srf) => { const haveWellsaid = speech.find((s) => s.vendor === 'wellsaid'); const haveNuance = speech.find((s) => s.vendor === 'nuance'); const haveDeepgram = speech.find((s) => s.vendor === 'deepgram'); + const haveIbm = speech.find((s) => s.vendor === 'ibm'); if (!haveGoogle || !haveAws || !haveMicrosoft || !haveWellsaid || !haveNuance) { const [r3] = await pp.query(sqlSpeechCredentialsForSP, account_sid); if (r3.length) { @@ -106,6 +114,10 @@ module.exports = (logger, srf) => { const deepgram = r3.find((s) => s.vendor === 'deepgram'); if (deepgram) speech.push(speechMapper(deepgram)); } + if (!haveIbm) { + const ibm = r3.find((s) => s.vendor === 'ibm'); + if (ibm) speech.push(speechMapper(ibm)); + } } } diff --git a/package-lock.json b/package-lock.json index 91c4a413..177cc767 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.6.1", + "@jambonz/realtimedb-helpers": "^0.6.2", "@jambonz/stats-collector": "^0.1.6", "@jambonz/time-series": "^0.2.5", "@opentelemetry/api": "^1.2.0", @@ -539,9 +539,9 @@ } }, "node_modules/@jambonz/realtimedb-helpers": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.6.1.tgz", - "integrity": "sha512-R+MYjgRH59ZLSfwaPC/iNgFMS4G1TECD95CNoAO6n7uVQMADOQPiecpBBRrXEp2aJvPvLqKcsGZbivCTO9p1Ew==", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.6.2.tgz", + "integrity": "sha512-hZNjEFGtMg5Rvn50P64qvTBZpN12iXML9rNJ83JxNk6eCznavhhJ/aw0K6ouetQ+wesvN22/RSk0I5HhAvVlbA==", "dependencies": { "@google-cloud/text-to-speech": "^4.0.3", "@grpc/grpc-js": "^1.7.3", @@ -552,7 +552,7 @@ "form-urlencoded": "^6.1.0", "google-protobuf": "^3.21.2", "ibm-watson": "^7.1.2", - "microsoft-cognitiveservices-speech-sdk": "^1.24.0", + "microsoft-cognitiveservices-speech-sdk": "^1.24.1", "redis": "^3.1.2", "undici": "^5.11.0" } @@ -4795,9 +4795,9 @@ } }, "node_modules/microsoft-cognitiveservices-speech-sdk": { - "version": "1.24.0", - "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.24.0.tgz", - "integrity": "sha512-26/lmzsRHgIzP03DSts1pqp+5UINdpDo35jnmi9QRzhYebtLrdEydwPR9TF0wa9TB+vbMeMFWD+gy9VKfWXAvQ==", + "version": "1.24.1", + "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.24.1.tgz", + "integrity": "sha512-7oAlVge4cPnCeNHeIVUQe4tKZmfGtsriD8rjl7uAoPcwG4hF3BXVVhUEkhlW+B8i5zVAJl3fH4BbAfZPCtrbvg==", "hasInstallScript": true, "dependencies": { "agent-base": "^6.0.1", @@ -7813,9 +7813,9 @@ } }, "@jambonz/realtimedb-helpers": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.6.1.tgz", - "integrity": "sha512-R+MYjgRH59ZLSfwaPC/iNgFMS4G1TECD95CNoAO6n7uVQMADOQPiecpBBRrXEp2aJvPvLqKcsGZbivCTO9p1Ew==", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.6.2.tgz", + "integrity": "sha512-hZNjEFGtMg5Rvn50P64qvTBZpN12iXML9rNJ83JxNk6eCznavhhJ/aw0K6ouetQ+wesvN22/RSk0I5HhAvVlbA==", "requires": { "@google-cloud/text-to-speech": "^4.0.3", "@grpc/grpc-js": "^1.7.3", @@ -7826,7 +7826,7 @@ "form-urlencoded": "^6.1.0", "google-protobuf": "^3.21.2", "ibm-watson": "^7.1.2", - "microsoft-cognitiveservices-speech-sdk": "^1.24.0", + "microsoft-cognitiveservices-speech-sdk": "^1.24.1", "redis": "^3.1.2", "undici": "^5.11.0" } @@ -11117,9 +11117,9 @@ } }, "microsoft-cognitiveservices-speech-sdk": { - "version": "1.24.0", - "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.24.0.tgz", - "integrity": "sha512-26/lmzsRHgIzP03DSts1pqp+5UINdpDo35jnmi9QRzhYebtLrdEydwPR9TF0wa9TB+vbMeMFWD+gy9VKfWXAvQ==", + "version": "1.24.1", + "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.24.1.tgz", + "integrity": "sha512-7oAlVge4cPnCeNHeIVUQe4tKZmfGtsriD8rjl7uAoPcwG4hF3BXVVhUEkhlW+B8i5zVAJl3fH4BbAfZPCtrbvg==", "requires": { "agent-base": "^6.0.1", "asn1.js-rfc2560": "^5.0.1", diff --git a/package.json b/package.json index 06a25e39..2e6265a9 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "dependencies": { "@jambonz/db-helpers": "^0.7.3", "@jambonz/http-health-check": "^0.0.1", - "@jambonz/realtimedb-helpers": "^0.6.1", + "@jambonz/realtimedb-helpers": "^0.6.2", "@jambonz/stats-collector": "^0.1.6", "@jambonz/time-series": "^0.2.5", "@opentelemetry/api": "^1.2.0",