From 7d16bdd77435c9f9e61f3faa02120e32f4ca6202 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Tue, 22 Aug 2023 20:22:39 +0700 Subject: [PATCH] feat fallback speech vendors (#220) * feat fallback speech vendors * wip * update verb specification --- db/jambones-sql.sql | 8 +++++ db/jambones.sqs | 69 +++++++++++++++++++++++++++++++++++----- db/upgrade-jambonz-db.js | 10 +++++- package-lock.json | 14 ++++---- package.json | 2 +- test/applications.js | 38 ++++++++++++++++++++-- 6 files changed, 121 insertions(+), 20 deletions(-) diff --git a/db/jambones-sql.sql b/db/jambones-sql.sql index 2cf24115..e0215482 100644 --- a/db/jambones-sql.sql +++ b/db/jambones-sql.sql @@ -483,6 +483,14 @@ speech_synthesis_label VARCHAR(64), speech_recognizer_vendor VARCHAR(64) NOT NULL DEFAULT 'google', speech_recognizer_language VARCHAR(64) NOT NULL DEFAULT 'en-US', speech_recognizer_label VARCHAR(64), +use_for_fallback_speech BOOLEAN DEFAULT false, +fallback_speech_synthesis_vendor VARCHAR(64) NOT NULL DEFAULT 'google', +fallback_speech_synthesis_language VARCHAR(12) NOT NULL DEFAULT 'en-US', +fallback_speech_synthesis_voice VARCHAR(64), +fallback_speech_synthesis_label VARCHAR(64), +fallback_speech_recognizer_vendor VARCHAR(64) NOT NULL DEFAULT 'google', +fallback_speech_recognizer_language VARCHAR(64) NOT NULL DEFAULT 'en-US', +fallback_speech_recognizer_label VARCHAR(64), created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, record_all_calls BOOLEAN NOT NULL DEFAULT false, PRIMARY KEY (application_sid) diff --git a/db/jambones.sqs b/db/jambones.sqs index c2ff76c0..249f7481 100644 --- a/db/jambones.sqs +++ b/db/jambones.sqs @@ -2018,8 +2018,8 @@ - 947.00 - 1303.00 + 1270.00 + 1425.00 262.00 @@ -2184,8 +2184,8 @@ - 916.00 - 1447.00 + 974.00 + 1496.00 228.00 @@ -2354,8 +2354,8 @@ 917.00 - 345.00 - 380.00 + 363.00 + 540.00 0 @@ -2500,10 +2500,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2958,7 +3011,7 @@ - + @@ -2967,7 +3020,7 @@ - + diff --git a/db/upgrade-jambonz-db.js b/db/upgrade-jambonz-db.js index a85d69f0..7877fc8f 100644 --- a/db/upgrade-jambonz-db.js +++ b/db/upgrade-jambonz-db.js @@ -164,7 +164,15 @@ const sql = { 'DROP INDEX speech_credentials_idx_1 ON speech_credentials', 'ALTER TABLE speech_credentials ADD COLUMN label VARCHAR(64)', 'ALTER TABLE applications ADD COLUMN speech_synthesis_label VARCHAR(64)', - 'ALTER TABLE applications ADD COLUMN speech_recognizer_label VARCHAR(64)' + 'ALTER TABLE applications ADD COLUMN speech_recognizer_label VARCHAR(64)', + 'ALTER TABLE applications ADD COLUMN use_for_fallback_speech BOOLEAN DEFAULT false', + 'ALTER TABLE applications ADD COLUMN fallback_speech_synthesis_vendor VARCHAR(64)', + 'ALTER TABLE applications ADD COLUMN fallback_speech_synthesis_language VARCHAR(12)', + 'ALTER TABLE applications ADD COLUMN fallback_speech_synthesis_voice VARCHAR(64)', + 'ALTER TABLE applications ADD COLUMN fallback_speech_synthesis_label VARCHAR(64)', + 'ALTER TABLE applications ADD COLUMN fallback_speech_recognizer_vendor VARCHAR(64)', + 'ALTER TABLE applications ADD COLUMN fallback_speech_recognizer_language VARCHAR(64)', + 'ALTER TABLE applications ADD COLUMN fallback_speech_recognizer_label VARCHAR(64)', ] }; diff --git a/package-lock.json b/package-lock.json index 3fbad0d0..a92c4356 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@jambonz/realtimedb-helpers": "^0.8.6", "@jambonz/speech-utils": "^0.0.15", "@jambonz/time-series": "^0.2.8", - "@jambonz/verb-specifications": "^0.0.28", + "@jambonz/verb-specifications": "^0.0.29", "@soniox/soniox-node": "^1.1.1", "argon2": "^0.30.3", "bent": "^7.3.12", @@ -2046,9 +2046,9 @@ } }, "node_modules/@jambonz/verb-specifications": { - "version": "0.0.28", - "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.28.tgz", - "integrity": "sha512-xbRbrhrgi0nGLk5e6vLs60zigDh45ywdgfBOClsVw+NwM66L6paGSPb0QCwVrdocG2vTOAXCpyb0aPXO+fL4sA==", + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.29.tgz", + "integrity": "sha512-jeYI+GN7Y5nXhdFG3SXvXaBlhCjIC+l5AcBywDDGxxyuuKRTukPS0MSvCtWPZP6H3wYYGqfJ4DR/vgtBF3pvyQ==", "dependencies": { "debug": "^4.3.4", "pino": "^8.8.0" @@ -11339,9 +11339,9 @@ } }, "@jambonz/verb-specifications": { - "version": "0.0.28", - "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.28.tgz", - "integrity": "sha512-xbRbrhrgi0nGLk5e6vLs60zigDh45ywdgfBOClsVw+NwM66L6paGSPb0QCwVrdocG2vTOAXCpyb0aPXO+fL4sA==", + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.29.tgz", + "integrity": "sha512-jeYI+GN7Y5nXhdFG3SXvXaBlhCjIC+l5AcBywDDGxxyuuKRTukPS0MSvCtWPZP6H3wYYGqfJ4DR/vgtBF3pvyQ==", "requires": { "debug": "^4.3.4", "pino": "^8.8.0" diff --git a/package.json b/package.json index 6e1edb0f..b4f5a973 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@jambonz/realtimedb-helpers": "^0.8.6", "@jambonz/speech-utils": "^0.0.15", "@jambonz/time-series": "^0.2.8", - "@jambonz/verb-specifications": "^0.0.28", + "@jambonz/verb-specifications": "^0.0.29", "@jambonz/lamejs": "^1.2.2", "@soniox/soniox-node": "^1.1.1", "argon2": "^0.30.3", diff --git a/test/applications.js b/test/applications.js index 58ec7ec8..7f932a1c 100644 --- a/test/applications.js +++ b/test/applications.js @@ -53,7 +53,7 @@ test('application tests', async(t) => { ]' } }); - t.ok(result.statusCode === 400, 'Cant create application with invalid app_josn'); + t.ok(result.statusCode === 400, 'Cant create application with invalid app_json'); /* add an application */ result = await request.post('/Applications', { @@ -81,7 +81,15 @@ test('application tests', async(t) => { "seekOffset": 8000,\ "actionHook": "/play/action"\ }\ - ]' + ]', + use_for_fallback_speech: 1, + fallback_speech_synthesis_vendor: 'google', + fallback_speech_synthesis_language: 'en-US', + fallback_speech_synthesis_voice: 'man', + fallback_speech_synthesis_label: 'label1', + fallback_speech_recognizer_vendor: 'google', + fallback_speech_recognizer_language: 'en-US', + fallback_speech_recognizer_label: 'label1' } }); t.ok(result.statusCode === 201, 'successfully created application'); @@ -102,6 +110,14 @@ test('application tests', async(t) => { }); t.ok(result.name === 'daveh' , 'successfully retrieved application by sid'); t.ok(result.messaging_hook.url === 'http://example.com/sms' , 'successfully retrieved messaging_hook from application'); + t.ok(result.use_for_fallback_speech === 1, 'successfully create use_for_fallback_speech'); + t.ok(result.fallback_speech_synthesis_vendor === 'google', 'successfully create fallback_speech_synthesis_vendor'); + t.ok(result.fallback_speech_synthesis_language === 'en-US', 'successfully create fallback_speech_synthesis_language'); + t.ok(result.fallback_speech_synthesis_voice === 'man', 'successfully create fallback_speech_synthesis_voice'); + t.ok(result.fallback_speech_synthesis_label === 'label1', 'successfully create fallback_speech_synthesis_label'); + t.ok(result.fallback_speech_recognizer_vendor === 'google', 'successfully create fallback_speech_recognizer_vendor'); + t.ok(result.fallback_speech_recognizer_language === 'en-US', 'successfully create fallback_speech_recognizer_language'); + t.ok(result.fallback_speech_recognizer_label === 'label1', 'successfully create fallback_speech_recognizer_label'); let app_json = JSON.parse(result.app_json); t.ok(app_json[0].verb === 'play', 'successfully retrieved app_json from application') @@ -126,7 +142,15 @@ test('application tests', async(t) => { }\ }\ ]', - record_all_calls: true + record_all_calls: true, + use_for_fallback_speech: 0, + fallback_speech_synthesis_vendor: 'microsoft', + fallback_speech_synthesis_language: 'en-US', + fallback_speech_synthesis_voice: 'woman', + fallback_speech_synthesis_label: 'label2', + fallback_speech_recognizer_vendor: 'microsoft', + fallback_speech_recognizer_language: 'en-US', + fallback_speech_recognizer_label: 'label2' } }); t.ok(result.statusCode === 204, 'successfully updated application'); @@ -140,6 +164,14 @@ test('application tests', async(t) => { app_json = JSON.parse(result.app_json); t.ok(app_json[0].verb === 'hangup', 'successfully updated app_json from application') t.ok(result.record_all_calls === 1, 'successfully updated record_all_calls from application') + t.ok(result.use_for_fallback_speech === 0, 'successfully update use_for_fallback_speech'); + t.ok(result.fallback_speech_synthesis_vendor === 'microsoft', 'successfully update fallback_speech_synthesis_vendor'); + t.ok(result.fallback_speech_synthesis_language === 'en-US', 'successfully update fallback_speech_synthesis_language'); + t.ok(result.fallback_speech_synthesis_voice === 'woman', 'successfully update fallback_speech_synthesis_voice'); + t.ok(result.fallback_speech_synthesis_label === 'label2', 'successfully update fallback_speech_synthesis_label'); + t.ok(result.fallback_speech_recognizer_vendor === 'microsoft', 'successfully update fallback_speech_recognizer_vendor'); + t.ok(result.fallback_speech_recognizer_language === 'en-US', 'successfully update fallback_speech_recognizer_language'); + t.ok(result.fallback_speech_recognizer_label === 'label2', 'successfully update fallback_speech_recognizer_label'); /* remove applications app_json*/ result = await request.put(`/Applications/${sid}`, {