This commit is contained in:
Quan HL
2023-08-11 13:30:11 +07:00
parent 95e8d942b8
commit 1fa853faa3
2 changed files with 7 additions and 15 deletions
+6 -7
View File
@@ -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;
/**
+1 -8
View File
@@ -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
};