From 5340231ef5e2b54eded7ada923e80aaa4e3510bd Mon Sep 17 00:00:00 2001 From: Quan HL Date: Tue, 4 Jun 2024 20:26:34 +0700 Subject: [PATCH] fix cannot update verbio engine_version --- lib/routes/api/speech-credentials.js | 2 ++ test/speech-credentials.js | 54 +++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/lib/routes/api/speech-credentials.js b/lib/routes/api/speech-credentials.js index 24badb76..a8bdc6bd 100644 --- a/lib/routes/api/speech-credentials.js +++ b/lib/routes/api/speech-credentials.js @@ -458,6 +458,7 @@ router.put('/:sid', async(req, res) => { options, deepgram_stt_uri, deepgram_stt_use_tls, + engine_version } = req.body; const newCred = { @@ -484,6 +485,7 @@ router.put('/:sid', async(req, res) => { options, deepgram_stt_uri, deepgram_stt_use_tls, + engine_version }; logger.info({o, newCred}, 'updating speech credential with this new credential'); obj.credential = encryptCredential(newCred); diff --git a/test/speech-credentials.js b/test/speech-credentials.js index 4bcf730e..f650212a 100644 --- a/test/speech-credentials.js +++ b/test/speech-credentials.js @@ -750,7 +750,7 @@ test('speech credentials tests', async(t) => { json: true, body: { vendor: 'aws', - labe: 'aws_polly_with_arn', + label: 'aws_polly_with_arn', use_for_tts: true, use_for_stt: false, role_arn: 'Arn::aws::role', @@ -767,6 +767,58 @@ test('speech credentials tests', async(t) => { }); t.ok(result.statusCode === 204, 'successfully deleted speech credential'); + /* add a credential for verbio */ + result = await request.post(`/Accounts/${account_sid}/SpeechCredentials`, { + resolveWithFullResponse: true, + auth: authUser, + json: true, + body: { + vendor: 'verbio', + use_for_tts: true, + use_for_stt: true, + client_id: 'client:id', + client_secret: 'client:secret', + engine_version: 'V1' + } + }); + t.ok(result.statusCode === 201, 'successfully added speech credential for Verbio'); + const verbioSid = result.body.sid; + + result = await request.get(`/Accounts/${account_sid}/SpeechCredentials/${verbioSid}`, { + resolveWithFullResponse: true, + simple: false, + auth: authAdmin, + json: true, + }); + t.ok(result.body.engine_version === "V1", 'successfully get verbio speech credential'); + + result = await request.put(`/Accounts/${account_sid}/SpeechCredentials/${verbioSid}`, { + resolveWithFullResponse: true, + auth: authUser, + json: true, + body: { + use_for_tts: true, + use_for_stt: true, + engine_version: 'V2' + } + }); + t.ok(result.statusCode === 204, 'successfully updated speech credential for verbio'); + + result = await request.get(`/Accounts/${account_sid}/SpeechCredentials/${verbioSid}`, { + resolveWithFullResponse: true, + simple: false, + auth: authAdmin, + json: true, + }); + t.ok(result.body.engine_version === "V2", 'successfully Updated verbio speech credential'); + + /* delete the credential */ + result = await request.delete(`/Accounts/${account_sid}/SpeechCredentials/${verbioSid}`, { + auth: authUser, + resolveWithFullResponse: true, + }); + t.ok(result.statusCode === 204, 'successfully deleted speech credential'); + /* Check google supportedLanguagesAndVoices */ result = await request.get(`/Accounts/${account_sid}/SpeechCredentials/speech/supportedLanguagesAndVoices?vendor=google`, { resolveWithFullResponse: true,