microsoft / BotFramework-WebChat

A highly-customizable web-based client for Azure Bot Services.
https://www.botframework.com/
MIT License
1.6k stars 1.55k forks source link

how to add custom speech in botframe work #1216

Closed Tamoormughal closed 6 years ago

Tamoormughal commented 6 years ago

I am working on Custom speech in bot framework.I add Bing simple speech it is working on my website: here is link :https://envolvebot.azurewebsites.net/

but now i want to know how can we add custom speech (LUIS custom speech) in our webchat bot? I create custom speech using : https://westus.cris.ai/Home/CustomSpeech Now i want to add it and want it to work like bing speech .

i am using following code.

`/! modernizr 3.6.0 (Custom Build) | MIT

aNY BODY Know how to do this ?

Thank in advance .

compulim commented 6 years ago

The existing SDK we consume is based on Bing Speech. And unfortunately, their SDK does not support CRIS.

Speech Services team just release a new SDK at Ignite (9/24). Their new SDK support their recently GA-ed Speech Services and CRIS. There are some works for us to do in order to consumer their new SDK.

sgellock commented 6 years ago

dup of #1217

soso-maitha commented 6 years ago

The existing SDK we consume is based on Bing Speech. And unfortunately, their SDK does not support CRIS.

Speech Services team just release a new SDK at Ignite (9/24). Their new SDK support their recently GA-ed Speech Services and CRIS. There are some works for us to do in order to consumer their new SDK.

@compulim Do you have any idea when Bot Framework WebChat will be supported with Custom Speech? I need this importantly.

soso-maitha commented 6 years ago

@Tamoormughal check this tutorial https://aischool.microsoft.com/en-us/conversational/learning-paths/building-an-intelligent-bot/adding-custom-speech-support , this is the bot code they are using for custom speech https://github.com/Microsoft/BuildAnIntelligentBot but this require a lot of work to integrate with your bot specially if you are already done with development. Also check this one it is very straight forward, i will try on my bot and will let you know https://channel9.msdn.com/Blogs/MVP-Azure/Cognitive-Services-Episode-9-Build-the-ultimate-chatbot-with-Custom-Speech

compulim commented 6 years ago

@soso-maitha this is the top priority work in our current cycle. We want to be as transparent as possible on this work. We are tracking the effort at #1336 and we will keep updating the work item as we progress thru.

I don't have a definite date for now because we are still early in development stage. We want to target 12/15 but there are some risks involved, which is outlined in the issue #1336. Can you subscribe thru that issue to track the work?

Btw, GA = general available, and in other words, it means the feature/product go production.

soso-maitha commented 6 years ago

@Tamoormughal Hi! I found the solution! Please follow these steps:

  1. Copy the all the code from CognitiveServices.js file from this project https://github.com/Microsoft/BuildAnIntelligentBot and replace it with the original CognitiveServices.js you have from WebChat (for me I prettified the code using https://www.prettifyjs.net/ in order to understand it first . You will notice that it considers both Custom Speech CRIS (search for wss://westus.stt.speech.microsoft.com) and Bing Speech (search for wss://speech.platform.bing.com) while in the standard webchat you will find only Bing speech url in the CognitiveServices.js)

  2. In the speechOptions , change the SpeechRecognizer to the following: const speechOptions = { speechRecognizer: new CognitiveServices.SpeechRecognizer({ subscriptionKey: 'yourCustomSpeechSubscriptionKey', recognitionAPI: 1, endpointId: 'yourCustomSpeechEndPointId', }),

Notes:

I tested it and it is working without issues! :) let me know if you need any further help.

regards,

Tamoormughal commented 5 years ago

hi @soso-maitha bundle of thanks it is working . one issue is this is not working on safari and iPhone. if you have any material kindly share it . Thanks in advance .

compulim commented 5 years ago

@Tamoormughal Cognitive Services use WebRTC for streaming sound clips. And there are some limitations on iOS:

Unfortunately, these are hard limitations due to platform restrictions.

jchomarat commented 5 years ago

Hello - I am not sure what is the status of this issue - but we also needed to inject a custom speech in the bot, via the webchat client (using the speech endpointId) - so we instantiated a webchat with an empty store, added a mic button, and attach events to it to actually call the speechSDK (microsoft.cognitiveservices.speech.sdk.bundle.js)

speechConfig = SpeechSDK.SpeechConfig.fromAuthorizationToken(authorizationToken, region); speechConfig.speechRecognitionLanguage = locale; speechConfig.endpointId = endpointId; reco = new SpeechSDK.SpeechRecognizer(speechConfig, audioConfig);

and handle all the events on the reco object.

The output is written in the chat box, so we just need to hit "enter" (we could also do it via actions) to send the corrected text to the bot.

It is far from being an elegant solution, but it does the job.

Any idea on when we will be able to use the standard webchat client with the ability to send a custom speech?

Best Julien