Как использовать новые службы речи Azure вместо Bing Speech в веб-чате - PullRequest
0 голосов
/ 18 октября 2018

У меня есть бот-чат, работающий нормально (я могу использовать речь с ним, а он возвращается с речью) с Bing Speech по следующей ссылке:

С опцией 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 API на AP Speech Services, так как Bing Speech удаляется.

Кто-нибудь знает, как это сделать длямой бот-чат?

1 Ответ

0 голосов
/ 22 января 2019

Служба когнитивной речи Azure не поддерживается в веб-чате v3. Но в веб-чат 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")
                );
...