如何在机器人中更改bing语音的语言

时间:2018-01-24 12:28:54

标签: speech-recognition botframework bing-speech

我在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'。

还有一种方法可以根据用户说的语言改变语言吗?

1 个答案:

答案 0 :(得分:1)

有2个不同的项目:语音输入(SpeechRecognizer)和语音输出(SpeechSynthesizer)

SpeechRecognizer

有一个可选的 locale 参数,您可以通过subscriptionKey传递,参见sources

export interface ICognitiveServicesSpeechRecognizerProperties {
    locale?: string,
    subscriptionKey?: string,
    fetchCallback?: (authFetchEventId: string) => Promise<string>,
    fetchOnExpiryCallback?: (authFetchEventId: string) => Promise<string>
}

如果没有提供(source),则会出现回退:

const locale = properties.locale || 'en-US';

SpeechSynthesizer

使用 gender voiceName 参数(sources):

export interface ICognitiveServicesSpeechSynthesisProperties {
    subscriptionKey?: string,
    gender?: SynthesisGender,
    voiceName?: string,
    fetchCallback?: (authFetchEventId: string) => Promise<string>,
    fetchOnExpiryCallback?: (authFetchEventId: string) => Promise<string>
}

有关这些参数的可能值,您可以在此处找到一个列表:https://docs.microsoft.com/en-us/azure/cognitive-services/speech/api-reference-rest/bingvoiceoutput#SupLocales