首页 > 解决方案 > Speech functionality not working in IFrame

问题描述

I have a bot client and in which I have enabled speech functionality. Everything works fine when I open the bot client in new window. Recently we have added this bot client site url in a page as IFrame. In this all the functionalities are working fine except speech functionality. When we are clicking on microphone icon nothing is happening.

Have tried in multiple browsers and devices, same issue in all the devices. Windows - Chrome, IE IPad, IPhone

Is it the expected behavior? or Do i need to update anything?

Please let me know if you want me to share any code.

Code.

 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');
        });

标签: botframeworkspeech-recognitionazure-cognitive-services

解决方案


为了让语音与 WebChat 一起工作,您需要做一些事情。

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

  2. 许多版本的主要浏览器不支持语音服务。确保您和您的用户仅使用受支持的浏览器或使用必应语音

  3. Chrome(以及未来可能的其他浏览器)会阻止麦克风访问,直到某些交互首先在 page/iFrame 上发生。你应该能够解决这个问题<iframe allow="microphone *">


推荐阅读