语音功能在 IFrame 中不起作用

Speech functionality not working in IFrame

我有一个机器人客户端,我在其中启用了语音功能。 当我在新 window 中打开机器人客户端时一切正常。 最近我们在页面中添加了这个 bot 客户端站点 url 作为 IFrame。 在这方面,除了语音功能外,所有功能都运行良好。 当我们点击麦克风图标时,什么也没有发生。

已在多种浏览器和设备中尝试过,所有设备都存在同样的问题。 Windows - Chrome, IE IPad, IPhone

这是预期的行为吗?或者我需要更新什么吗?

如果你想让我分享任何代码,请告诉我。

代码。

 speechOptions = {
        speechRecognizer: new CognitiveServices.SpeechRecognizer({
            subscriptionKey:
                'xxx'
        }),
        speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
            gender: CognitiveServices.SynthesisGender.Female,
            subscriptionKey: 'xxx'
            voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, ZiraRUS)'
        })
    };
    BotChat.App({
        botConnection: botConnection,
        user: { id: model.userId, Username: LoginUser,},
        bot: { id: model.botId, name: model.botName },
        resize: 'window',
        speechOptions: speechOptions,
        locale: 'en',
        sendTypingIndicator: true
    }, document.getElementById('BotChatElement'));

    botConnection
        .postActivity({
            from: user,
            name: 'requestWelcomeDialog',
            type: 'event',
            value: ''
        })
        .subscribe(function (id) {
            console.log('"trigger requestWelcomeDialog" sent');
        });

要使语音与 WebChat 配合使用,您需要做一些事情。

  1. 确保您使用带有来自 Azure 门户的嵌入代码的 WebChat 版本。您必须使用one of the WebChat bundles(如果您希望它在 IE 中工作,请使用其中一个 es5 包)

  2. Speech Services are not supported on many version of major browsers. Ensure that you and your users are only using supported browsers or use Bing Speech

  3. Chrome(将来可能还有其他浏览器)blocks microphone access until certain interactions occur first on the page/iFrame。您应该可以使用 <iframe allow="microphone *">

  4. 来解决这个问题