如何更改 Azure 文本转语音中的声音?
How do I change the voice in Azure text-to-speech?
我尝试更改我的 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);
但我只听到美国的声音。我错过了什么?
SpeechRecognizer 用于将语音转换为文本,如果您想将文本转换为语音,则需要使用 SpeechSynthesizer。
正如 Ryan 所指出的,您需要使用 SpeechSynthesizer 而不是 SpeechRecognizer。这是 TTS sample code on github 的 link。
该示例应该可以解决问题并让您继续前进。请务必注意 audioConfig 和 speechConfig 属性。例如,speechSynthesisVoiceName
需要使用提供的语音名称标签进行更改 here. (Further down that page are 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);
我尝试更改我的 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);
但我只听到美国的声音。我错过了什么?
SpeechRecognizer 用于将语音转换为文本,如果您想将文本转换为语音,则需要使用 SpeechSynthesizer。
正如 Ryan 所指出的,您需要使用 SpeechSynthesizer 而不是 SpeechRecognizer。这是 TTS sample code on github 的 link。
该示例应该可以解决问题并让您继续前进。请务必注意 audioConfig 和 speechConfig 属性。例如,speechSynthesisVoiceName
需要使用提供的语音名称标签进行更改 here. (Further down that page are 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);