Cloudkibo / ChatBot

AI Chat Bot
0 stars 1 forks source link

Enable audio in web widget #42

Open sojharo opened 7 years ago

sojharo commented 7 years ago

Audio in API.AI’s own web widget is already enabled and can be tested here

https://api.cloudkibo.com/#/login

but the response of bot is not in audio speech.

In this task, I tried again to use the library of Api.Ai to enable voice input on our own widget hosted on kiboengage. It is still giving errors. Later, I went to the documentation of the library, I found that they have discontinued the audio input in the latest beta of their own library.

https://github.com/api-ai/apiai-javascript-client#200-beta21

I might be having problems because of this.

However, later after exploring more, I found the following gist provided by API.AI which is using HTML 5 Speech Recognition API.

https://gist.github.com/Gugic/cfc008599fa9a82eeba4127648009132

I was able to test the gist. and it was able to generate the text from the voice input I gave and then it asked the response from API.AI. It gave the JSON response to my query.

screen shot 2017-07-06 at 4 08 16 pm

This HTML 5 Speech Recognition seems relatively new but it is working very fine and is natively supported in Chrome. It might be better alternative to Google Speech API which might be costly.

Here are the documentation and one article about it.

https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition

https://shapeshed.com/html5-speech-recognition-api/

Next, I will work on our kiboengage and use this speech recognition api in it to take speech input. For speech output we would tts api of api.ai.

sojharo commented 7 years ago

One drawback to Speech Recognition API of HTML 5 is that it is currently only supported by Chrome.