我在botframeowrk中使用bing语音,如下所示:
var speechOptions =
{
speechRecognizer: new CognitiveServices.SpeechRecognizer(
{
subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY'
}),
speechSynthesizer: new CognitiveServices.SpeechSynthesizer(
{
subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY',
gender: CognitiveServices.SynthesisGender.Female,
voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)'
})
}
我想将语言从"en-us"更改为其他语言,我应该添加任何选项,例如 lang:"it-it"。
还有没有办法根据用户所说的语言来更改语言?
有 2 个不同的项目:语音输入(语音识别器)和语音输出(语音合成器)
语音识别器
有一个可选的locale
参数,您可以像传递subscriptionKey
一样传递,请参阅源代码:
export interface ICognitiveServicesSpeechRecognizerProperties {
locale?: string,
subscriptionKey?: string,
fetchCallback?: (authFetchEventId: string) => Promise<string>,
fetchOnExpiryCallback?: (authFetchEventId: string) => Promise<string>
}
如果未提供,则有一个回退(来源):
const locale = properties.locale || 'en-US';
语音合成器
使用gender
和voiceName
参数(源):
export interface ICognitiveServicesSpeechSynthesisProperties {
subscriptionKey?: string,
gender?: SynthesisGender,
voiceName?: string,
fetchCallback?: (authFetchEventId: string) => Promise<string>,
fetchOnExpiryCallback?: (authFetchEventId: string) => Promise<string>
}
有关这些参数的可能值,您可以在此处找到列表:https://learn.microsoft.com/en-us/azure/cognitive-services/speech/api-reference-rest/bingvoiceoutput#SupLocales