mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-07-23 04:31:47 +00:00
fix
This commit is contained in:
+13
-32
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user