From 1fa853faa3c54046508f6517a9f274ee9b55d8be Mon Sep 17 00:00:00 2001 From: Quan HL Date: Fri, 11 Aug 2023 13:30:11 +0700 Subject: [PATCH] wip --- lib/synth-audio.js | 13 ++++++------- lib/utils.js | 9 +-------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/synth-audio.js b/lib/synth-audio.js index 2bd94e6..1e23135 100644 --- a/lib/synth-audio.js +++ b/lib/synth-audio.js @@ -19,8 +19,7 @@ const { createNuanceClient, createKryptonClient, createRivaClient, - noopLogger, - isValidHttpOrWsUrl + noopLogger } = require('./utils'); const getNuanceAccessToken = require('./get-nuance-access-token'); const { @@ -313,22 +312,22 @@ const synthMicrosoft = async(logger, { filePath }) => { try { - const {api_key: apiKey, region, use_custom_tts, custom_tts_endpoint} = credentials; + const {api_key: apiKey, region, use_custom_tts, custom_tts_endpoint, custom_tts_endpoint_url} = credentials; const trimSilence = filePath.endsWith('.r8'); let content = text; let speechConfig; - if (use_custom_tts && isValidHttpOrWsUrl(custom_tts_endpoint)) { + if (use_custom_tts && custom_tts_endpoint_url) { if (apiKey) { - speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint, apiKey); + speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint_url, apiKey); } else { - speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint); + speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint_url); } } else { speechConfig = SpeechConfig.fromSubscription(apiKey, region); } speechConfig.speechSynthesisLanguage = language; speechConfig.speechSynthesisVoiceName = voice; - if (use_custom_tts && !isValidHttpOrWsUrl(custom_tts_endpoint)) { + if (use_custom_tts && custom_tts_endpoint) { speechConfig.endpointId = custom_tts_endpoint; /** diff --git a/lib/utils.js b/lib/utils.js index 2f6562f..4e3ed3c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -106,12 +106,6 @@ const createRivaClient = async(rivaUri) => { return client; }; -const isValidHttpOrWsUrl = (url) => { - const pattern = new RegExp('^(https?:\/\/|wss?:\/\/)'); - return !!url.match(pattern); -}; - - module.exports = { makeSynthKey, makeNuanceKey, @@ -122,6 +116,5 @@ module.exports = { createRivaClient, makeBasicAuthHeader, NUANCE_AUTH_ENDPOINT, - noopLogger, - isValidHttpOrWsUrl + noopLogger };