【问题标题】:voice xml:lang="en-US" xml:gender="Male" name="Microsoft Server Speech Text is always in Female voicevoice xml:lang="en-US" xml:gender="Male" name="Microsoft 服务器语音文本始终为女性语音
【发布时间】:2018-05-14 16:04:08
【问题描述】:

我只是想开发一个将文本转换为语音的功能。这里的问题是,转换总是发生在女声中,即使我已将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"));
        }
    )
}

【问题讨论】:

    标签: node.js speech-recognition text-to-speech azure-cognitive-services bing-speech


    【解决方案1】:

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

    • gender: 可选属性指示语音的首选性别以说出包含的文本。枚举值为:“male”、“female”、“neutral”或空字符串“”。

    • name:可选属性指示特定于处理器的语音名称以说出包含的文本。该值可以是空格分隔的名称列表,从上至下排序或空字符串“”。因此,名称不得包含任何空格。

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

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

    【讨论】:

      猜你喜欢
      • 2022-10-20
      • 1970-01-01
      • 2017-10-29
      • 2011-09-18
      • 2019-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-18
      相关资源
      最近更新 更多