如何更改语音输入的直线语言? C#
How to change the Language in Direct Line for Voice Input? C#
您好,默认语言是英语,我想更改为德语。我目前使用选项 3,但它仍然无法正常工作。怎么了?
<script
> src="https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js"></script>
> <script>
> const params = BotChat.queryParams(location.search);
> const user = {
> id: params['userid'] || 'userid',
> name: params['username'] || 'username'
> };
>
> const bot = {
> id: params['botid'] || 'botid',
> name: params['botname'] || 'botname'
> };
>
> window.botchatDebug = params['debug'] && params['debug'] === 'true';
>
> const speechOptions =
>
> speechRecognizer: new CognitiveServices.SpeechRecognizer({ SpeechRecognitionLanguage: 'de-de', subscriptionKey: 'xxxxx' }),
> speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
> locale: 'de-de',
> gender: CognitiveServices.SynthesisGender.Female,
> subscriptionKey: 'xxxxxxx',
> voiceName: 'Microsoft Server Speech Text to Speech Voice (de-DE, KatjaNeural)'
> })
> };
> BotChat.App({
> bot: bot,
> locale: params['de-DE'],
> resize: 'detect',
>
> speechOptions: speechOptions,
> user: user,
>
> directLine: {
> domain: params['domain'],
> secret: params['s'],
> token: params['t'],
> webSocket: params['webSocket'] && params['webSocket'] === 'true' // defaults to true
> }
> }, document.getElementById('BotChatGoesHere')); </script> </body> </html>
有什么想法或代码可以解决我的问题吗?
这不起作用的原因是 "params" 中没有关联值可供读取。根据上面的代码,"params" 设置为 location.search
,在我的例子中,读作 {"": "undefined"}
因为 location.search
自行解析为 ""
。此外,您将 "de-DE" 视为传递的值,而实际上您提供的是一个键(不存在),然后 return 一个值(不存在)。
如果你真的想使用"params",那么给它分配一个键值对,就像这样params['locale'] = 'de-DE'
。
如果您想放弃使用 "params",那么只需直接指定语言环境,如下所示:
locale: params['de-DE']
到
locale: 'de-DE'
.
希望得到帮助!!
解决了。
- 将 Azure 中的直线语音通道添加到您的语音认知服务。
像这样添加语言参数:
const speechOptions = {
speechRecognizer: new CognitiveServices.SpeechRecognizer({ subscriptionKey: 'XXXXX', locale: 'de-DE' }),
speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
gender: CognitiveServices.SynthesisGender.Female,
subscriptionKey: 'XXXXX',
voiceName: 'Microsoft Server Speech Text to Speech Voice (de-DE, KatjaNeutral)', location: 'de-DE'
})
};
现在机器人正在 WebChat 中收听 German Lang 以及上述 'de-DE'.
的参数
您好,默认语言是英语,我想更改为德语。我目前使用选项 3,但它仍然无法正常工作。怎么了?
<script
> src="https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js"></script>
> <script>
> const params = BotChat.queryParams(location.search);
> const user = {
> id: params['userid'] || 'userid',
> name: params['username'] || 'username'
> };
>
> const bot = {
> id: params['botid'] || 'botid',
> name: params['botname'] || 'botname'
> };
>
> window.botchatDebug = params['debug'] && params['debug'] === 'true';
>
> const speechOptions =
>
> speechRecognizer: new CognitiveServices.SpeechRecognizer({ SpeechRecognitionLanguage: 'de-de', subscriptionKey: 'xxxxx' }),
> speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
> locale: 'de-de',
> gender: CognitiveServices.SynthesisGender.Female,
> subscriptionKey: 'xxxxxxx',
> voiceName: 'Microsoft Server Speech Text to Speech Voice (de-DE, KatjaNeural)'
> })
> };
> BotChat.App({
> bot: bot,
> locale: params['de-DE'],
> resize: 'detect',
>
> speechOptions: speechOptions,
> user: user,
>
> directLine: {
> domain: params['domain'],
> secret: params['s'],
> token: params['t'],
> webSocket: params['webSocket'] && params['webSocket'] === 'true' // defaults to true
> }
> }, document.getElementById('BotChatGoesHere')); </script> </body> </html>
有什么想法或代码可以解决我的问题吗?
这不起作用的原因是 "params" 中没有关联值可供读取。根据上面的代码,"params" 设置为 location.search
,在我的例子中,读作 {"": "undefined"}
因为 location.search
自行解析为 ""
。此外,您将 "de-DE" 视为传递的值,而实际上您提供的是一个键(不存在),然后 return 一个值(不存在)。
如果你真的想使用"params",那么给它分配一个键值对,就像这样params['locale'] = 'de-DE'
。
如果您想放弃使用 "params",那么只需直接指定语言环境,如下所示:
locale: params['de-DE']
到
locale: 'de-DE'
.
希望得到帮助!!
解决了。
- 将 Azure 中的直线语音通道添加到您的语音认知服务。
像这样添加语言参数:
const speechOptions = { speechRecognizer: new CognitiveServices.SpeechRecognizer({ subscriptionKey: 'XXXXX', locale: 'de-DE' }), speechSynthesizer: new CognitiveServices.SpeechSynthesizer({ gender: CognitiveServices.SynthesisGender.Female, subscriptionKey: 'XXXXX', voiceName: 'Microsoft Server Speech Text to Speech Voice (de-DE, KatjaNeutral)', location: 'de-DE' }) };
现在机器人正在 WebChat 中收听 German Lang 以及上述 'de-DE'.
的参数