voice xml:lang="en-US" xml:gender="Male" name="Microsoft 服务器语音文本始终为女声

voice xml:lang="en-US" xml:gender="Male" name="Microsoft Server Speech Text is always in Female voice

我只是想开发一个将文本转换为语音的功能。这里的问题是,转换总是发生在女声中,即使我已将 xml:gender 指定为男声。这是我的功能,无论如何我可以将我的文本转换为男声音频吗?

textToSpeech("This is a test to check the conversion of text to speech");
function textToSpeech(text: string) {
    const requestOptions: request.CoreOptions = {
        headers: {
            "Ocp-Apim-Subscription-Key": config.speech.bingSpeech.key1,
        }
    };
    request.post(
        `${config.speech.bingSpeech.authEndPoint}/issueToken`,
        requestOptions,
        (err, response, body) => {
            const accessToken = response.body;
            const payLoad = `
            <speak version="1.0" xml:lang="en-US">
            <voice xml:lang="en-US" xml:gender="Male" name="Microsoft Server Speech Text to Speech Voice (en-US, ZiraRus)">
            ${text}
            </voice>
            </speak>
            `;
            const requestOptions: request.CoreOptions = {
                headers: {
                    "X-Microsoft-OutputFormat": "audio-16khz-128kbitrate-mono-mp3",
                    "Content-Type": "application/ssml+xml",
                    "Host": "speech.platform.bing.com",
                    "Content-Length": payLoad.length,
                    "Authorization": "Bearer " + accessToken,
                    "User-Agent": "NodeJS"
                },
                body: payLoad
            };

            request.post(
                config.speech.bingSpeech.synthesizeUrl,
                requestOptions
            ).pipe(fs.createWriteStream(__dirname + "/output.mp3"));
        }
    )
}

根据您的描述,我检查了3.2.1 voice Element关于gendername的属性如下:

  • gender: optional attribute indicating the preferred gender of the voice to speak the contained text. Enumerated values are: "male", "female", "neutral", or the empty string "".

  • name: optional attribute indicating a processor-specific voice name to speak the contained text. The value may be a space-separated list of names ordered from top preference down or the empty string "". As a result a name must not contain any white space.

根据您的代码,我检查了 Supported locales and voice fonts:

对于男声,您可能还需要将 voice 元素的 name 属性设置为 Microsoft Server Speech Text to Speech Voice (en-US, BenjaminRUS)