【问题标题】:How do I change the voice in Azure text-to-speech?如何更改 Azure 文本转语音中的语音?
【发布时间】:2021-09-06 03:10:16
【问题描述】:

我尝试将我的 React 网站更改为使用英国语音:

const voice = "Microsoft Server Speech Text to Speech Voice (en-GB, LibbyNeural)"
speechConfig.speechSynthesisVoiceName = voice;
speechConfig.speechRecognitionLanguage = "en-GB";
const audioConfig = AudioConfig.fromDefaultMicrophoneInput();

return new SpeechRecognizer(speechConfig, audioConfig);

但我所听到的只是美国的声音。我错过了什么?

【问题讨论】:

标签: reactjs azure text-to-speech


【解决方案1】:

正如 Ryan 所指出的,您需要使用 SpeechSynthesizer 而不是 SpeechRecognizer。这是TTS sample code on github的链接。

该示例应该可以解决问题并让您继续前进。请务必记下 audioConfig 和 speechConfig 属性。例如,speechSynthesisVoiceName 需要更改使用here 提供的语音名称标签。 (该页面下方是standard voices)。而speechRecognitionLanguage 将被替换为speechSynthesisLanguage。这些只是几个示例,但 github 示例应该可以清楚地说明一切。

var audioConfig = sdk.AudioConfig.fromAudioFileOutput(filename);
var speechConfig = sdk.SpeechConfig.fromSubscription(settings.subscriptionKey, settings.serviceRegion);

// setting the synthesis language, voice name, and output audio format.
// see https://aka.ms/speech/tts-languages for available languages and voices
speechConfig.speechSynthesisLanguage = settings.language;
speechConfig.speechSynthesisVoiceName = "en-US-GuyNeural";

// create the speech synthesizer.
var synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig);

【讨论】:

    【解决方案2】:

    SpeechRecognizer 用于将语音转换为文本,如果要将文本转换为语音,则需要使用 SpeechSynthesizer。

    【讨论】:

      猜你喜欢
      • 2021-02-26
      • 1970-01-01
      • 1970-01-01
      • 2019-01-06
      • 2017-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-14
      相关资源
      最近更新 更多