change edge tts _SSMLTemplate

This commit is contained in:
afred 2025-01-04 15:33:10 +08:00
parent da0210a6a1
commit a459703424
1 changed files with 8 additions and 16 deletions

View File

@ -233,23 +233,15 @@ export class MsEdgeTTS {
} }
private _SSMLTemplate(input: string, options: ProsodyOptions = {}): string { private _SSMLTemplate(input: string, options: ProsodyOptions = {}): string {
// 对 input 进行特殊字符替换 // in case future updates to the edge API block these elements, we'll be concatenating strings.
input = input
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
// 合并默认选项与传入选项
options = { ...new ProsodyOptions(), ...options }; options = { ...new ProsodyOptions(), ...options };
return `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="${this._voiceLocale}">
return ` <voice name="${this._voice}">
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="${this._voiceLocale}"> <prosody pitch="${options.pitch}" rate="${options.rate}" volume="${options.volume}">
<voice name="${this._voice}"> ${input}
<prosody pitch="${options.pitch}" rate="${options.rate}" volume="${options.volume}"> </prosody>
${input} </voice>
</prosody> </speak>`;
</voice>
</speak>`;
} }
/** /**