diff --git a/lib/synth-audio.js b/lib/synth-audio.js index b07994f..514cb72 100644 --- a/lib/synth-audio.js +++ b/lib/synth-audio.js @@ -303,27 +303,7 @@ const synthIbm = async(logger, {credentials, stats, voice, text}) => { } }; -async function synthMicrosoft(logger, { - credentials, - stats, - language, - voice, - text, - filePath -}) { - const synthFunc = process.env.JAMBONZ_ONPREM_AZURE_SYNTHESIZE_BY_HTTP ? - _synthMicrosoftByHttp : _synthMicrosoftBySdk; - return await synthFunc(logger, { - credentials, - stats, - language, - voice, - text, - filePath - }); -} - -async function _synthMicrosoftByHttp(logger, { +async function _synthOnPremMicrosoft(logger, { credentials, stats, language, @@ -364,7 +344,7 @@ async function _synthMicrosoftByHttp(logger, { } } -const _synthMicrosoftBySdk = async(logger, { +const synthMicrosoft = async(logger, { credentials, stats, language, @@ -374,18 +354,19 @@ const _synthMicrosoftBySdk = async(logger, { }) => { try { const {api_key: apiKey, region, use_custom_tts, custom_tts_endpoint, custom_tts_endpoint_url} = credentials; + if (use_custom_tts && custom_tts_endpoint_url) { + return await _synthOnPremMicrosoft(logger, { + credentials, + stats, + language, + voice, + text, + filePath + }); + } const trimSilence = filePath.endsWith('.r8'); let content = text; - let speechConfig; - if (use_custom_tts && custom_tts_endpoint_url) { - if (apiKey) { - speechConfig = SpeechConfig.FromHost(new URL(custom_tts_endpoint_url), apiKey); - } else { - speechConfig = SpeechConfig.FromHost(new URL(custom_tts_endpoint_url)); - } - } else { - speechConfig = SpeechConfig.fromSubscription(apiKey, region); - } + const speechConfig = SpeechConfig.fromSubscription(apiKey, region); speechConfig.speechSynthesisLanguage = language; speechConfig.speechSynthesisVoiceName = voice; if (use_custom_tts && custom_tts_endpoint) {