This commit is contained in:
Quan HL
2023-08-11 16:04:11 +07:00
parent 1fa853faa3
commit a0e2fe167c
+6 -5
View File
@@ -318,23 +318,24 @@ const synthMicrosoft = async(logger, {
let speechConfig;
if (use_custom_tts && custom_tts_endpoint_url) {
if (apiKey) {
speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint_url, apiKey);
speechConfig = SpeechConfig.fromEndpoint(new URL(custom_tts_endpoint_url), apiKey);
} else {
speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint_url);
speechConfig = SpeechConfig.fromEndpoint(new URL(custom_tts_endpoint_url));
}
} else {
speechConfig = SpeechConfig.fromSubscription(apiKey, region);
}
speechConfig.speechSynthesisLanguage = language;
speechConfig.speechSynthesisVoiceName = voice;
if (use_custom_tts && custom_tts_endpoint) {
if (use_custom_tts && custom_tts_endpoint ) {
speechConfig.endpointId = custom_tts_endpoint;
}
if (use_custom_tts && !content.startsWith('<speak')) {
/**
* Note: it seems that to use custom voice ssml is required with the voice attribute
* Otherwise sending plain text we get "Voice does not match"
*/
if (!content.startsWith('<speak')) content = `<speak>${text}</speak>`;
content = `<speak>${text}</speak>`;
}
speechConfig.speechSynthesisOutputFormat = trimSilence ?
SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm :