This is the code I used. Create Speech API service and add direct line channel with default site to the bot setup in azure.
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Web Chat: Cognitive Services Speech Services using JavaScript</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Cognitive Services Speech Services adapter is only available in full bundle -->
<!--
This CDN points to the latest official release of Web Chat. If you need to test against Web Chat's latest bits, please refer to using Web Chat's latest bits:
https://github.com/microsoft/BotFramework-WebChat#how-to-test-with-web-chats-latest-bits
-->
<script crossorigin="anonymous" src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<style>
html,
body {
height: 100%;
}
body {
margin: 0;
}
#webchat {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="webchat" role="main"></div>
<script>
(async function () {
let authorizationToken;
let region;
const speechServicesTokenRes = await fetch(
'https://<your-speech-service-region-eg-uksouth>.api.cognitive.microsoft.com/sts/v1.0/issueToken',
{ method: 'POST', headers: { 'Ocp-Apim-Subscription-Key': '<your-speech-api-key>' } }
);
if (speechServicesTokenRes.status === 200) {
region = '<your-azure-region-eg-uksouth>',
authorizationToken = await speechServicesTokenRes.text()
} else {
return (new Error('error!'))
}
const webSpeechPonyfillFactory = await window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory({
credentials: {
authorizationToken: authorizationToken,
region: region
}
});
var dl = window.WebChat.createDirectLine({ secret: '<your-directline-default-site-secret-key>' });
window.WebChat.renderWebChat({
directLine: dl,
webSpeechPonyfillFactory: webSpeechPonyfillFactory
}, document.getElementById('webchat'));
})().catch(err => console.error(err));
</script>
</body>
</html>