【问题标题】:How do I use the new Azure Speech Services instead of Bing Speech in web chat如何在网络聊天中使用新的 Azure 语音服务而不是 Bing 语音
【发布时间】:2019-03-23 06:41:17
【问题描述】:

我有一个网络聊天机器人工作正常(我可以使用语音并返回语音)使用以下链接的必应语音:

使用选项 3:

https://github.com/Microsoft/BotFramework-Samples/blob/master/docs-samples/web-chat-speech/index.html

  const speechOptions = {
    speechRecognizer: new CognitiveServices.SpeechRecognizer({ subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY' }),
    speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
      gender: CognitiveServices.SynthesisGender.Female,
      subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY',
      voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)'
    })
  };

但是,由于 Bing Speech 即将停用,我正在尝试从 Bing Speech API 切换到 Speech Services AP。

有人知道如何为我的网络聊天机器人执行此操作吗?

【问题讨论】:

  • 您还需要这方面的帮助吗?您使用的是哪个版本(3 或 4)的 SDK?
  • @StevenKanberg 是的 - 此处描述了该问题:github.com/Microsoft/BotFramework-WebChat/issues/1217 似乎尚不支持。我不确定如何找到我当前的 Bing Speech SDK 版本 - 我是从认知服务中的 Azure 门户构建的 - Bing Speech
  • 由于 Bing Speech 已被弃用并且基本上已经消失,我不会担心您拥有的 SDK 版本。相反,我将致力于开发新的认知服务语音 API 或迁移您的旧 API。您可以在此处阅读有关如何执行此操作的说明:docs.microsoft.com/en-us/azure/cognitive-services/…

标签: node.js azure botframework web-chat bing-speech


【解决方案1】:

webchat v3 不支持 azure 的认知语音服务。但是在 webchat v4 中,您可以通过以下代码进行集成

const config = {
                    method: "POST",
                    headers: {
                        Authorization:
                            "Bearer  xxwebchatsecretkeyxx"
                    }
                };
     const res = await fetch(
                    "https://directline.botframework.com/v3/directline/tokens/generate",
                    config
                );

                const subscriptionKey = "speech service subscription key";

                const { token } = await res.json();

                let directLine = window.WebChat.createDirectLine({ token });
    window.WebChat.renderWebChat(
                        {
                            directLine,
                            webSpeechPonyfillFactory: await window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory(
                                {
                                    region: "westus",
                                    subscriptionKey
                                }
                            ),
                            userID: model.id,
                            styleSet,
                            store
                        },
                   document.getElementById("webchat")
                );

【讨论】:

  • 如何指定语音名称?此示例中似乎缺少该参数。
猜你喜欢
  • 1970-01-01
  • 2019-06-29
  • 1970-01-01
  • 1970-01-01
  • 2014-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多