Botframework 如何更改语音输入的直连语言?C#
大家好,默认语言是英语,我想换成德语。我目前使用选项3,但它仍然不起作用。怎么了Botframework 如何更改语音输入的直连语言?C#,botframework,chatbot,direct-line-botframework,Botframework,Chatbot,Direct Line Botframework,大家好,默认语言是英语,我想换成德语。我目前使用选项3,但它仍然不起作用。怎么了 <script > src="https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js"></script> > <script> > const params = BotChat.queryParams(location.search); >
<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>
src=”https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js">
>
>const params=BotChat.queryParams(location.search);
>常量用户={
>id:params['userid']| |'userid',
>名称:params['username']| |'username'
> };
>
>const bot={
>id:params['botid']| |'botid',
>名称:params['botname']| |'botname'
> };
>
>window.botchatDebug=params['debug']&¶ms['debug']='true';
>
>常数扬声器=
>
>speechRecognizer:新的认知服务。speechRecognizer({SpeechRecognitionLanguage:'de de',subscriptionKey:'xxxxx'}),
>speechSynthesizer:新的认知服务。speechSynthesizer({
>地区:'de de',
>性别:认知服务。综合性别。女性,
>subscriptionKey:'xxxxxxx',
>voiceName:“Microsoft服务器语音文本到语音语音(de de,KatjaNeural)”
> })
> };
>BotChat.App({
>机器人:机器人,
>语言环境:params['de-de'],
>调整大小:“检测”,
>
>语音提示:语音提示,
>用户:用户,,
>
>直拨电话:{
>域:参数['domain'],
>秘密:params['s'],
>令牌:params['t'],
>webSocket:params['webSocket']&¶ms['webSocket']=='true'//默认为true
> }
>},document.getElementById('botchatgoesher');
有什么想法或代码可以解决我的问题吗?这不起作用的原因是“参数”中没有相关的值可供读取。基于上述代码,“params”被设置为
location.search
,在我的例子中,它被理解为{”“:“undefined”}
,因为location.search
本身解析为”
。此外,您将“de de”视为传入的值,而实际上您提供的键(不存在)将返回一个值(不存在该值)
如果你真的想使用“params”,那么给它分配一个键值对,就像这样params['locale']='de'
如果您想放弃使用“params”,那么只需直接指定区域设置,如下所示:
locale:params['de-de']
到
locale:'de de'
希望有帮助 解决了它
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中的德语Lang以及上面提到的“de de”参数。接受/向上投票答案服务于更大的堆栈溢出社区和任何有类似问题的人。如果你觉得我的回答足够,请“接受”并投票表决。如果没有,让我知道我还能提供什么帮助!我明白你的意思!我会在白天测试它,让你知道它是否有效。谢谢。所以输入仍然是英语,输出现在是德语,但是如何同时获得德语?