Please reload

Recent Posts
Featured Posts

Speech to Text API in Lightning

August 26, 2019

 

In this post, I will be showing how speech recognition can be added in Salesforce Lightning UI using Google's Speech API.

 

 

The JavaScript Web Speech API allows spoken text to be converted into written text in a web browser. You can speak into a microphone and the API will translate speech to text.

 

Its one of the easiest ways to integrate  speech recognition in Salesforce because it does not require any authentication. However, it does have cons. You are only limited to 50 queries per day and It only works on Chrome version 25 or later and Firefox.

 

To add voice you should initiate SpeechRecognition & webkitSpeechRecognition interfaces in JavaScript. SpeechRecognition is for Chrome and webkitSpeechRecognition is for FireFox.

 

In Salesforce, I had to use a Visualforce page as the interfaces or the browser's window object is not recognized in the Lightning component JavaScript controller. The page is embedded on the page layout using the Visualforce standard lightning component.

 

The records are retrieved from Leads object and displayed on the component. You have to click the mic button for the API to listen. After the conversion from voice to text, you have a string to work with. From there on, you can create your own logic to handle speech.  My solution looks for an action word and first name(s), from that point on it will take appropriate action. There are loops in this solution, however, this POC was only to figure out how the API works.

 

 

This API opens up an opportunity to easily add voice capability to business use cases. 

 

Demo:

https://www.youtube.com/watch?v=CESfFJ2Bg1M&feature=youtu.be

 

Code Repo:

https://github.com/mhlangano/VoiceToText/tree/master/voiceToText/force-app/main/default

 

References:

1. https://w3c.github.io/speech-api/speechapi.html

2. https://www.google.com/intl/en/chrome/demos/speech.html

3. https://pythonspot.com/speech-recognition-using-google-speech-api/

4. https://ourcodeworld.com/articles/read/59/how-to-convert-voice-to-text-with-javascript-webkitspeechrecognition-api-easily

5. https://www.tutorialspoint.com/speech-recognition-in-python-using-google-speech-api

 

 

Please reload

Follow Me
Please reload

Search By Tags
Please reload

Archive
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square

Data Visualization with Chart.JS in Lightning Components

October 3, 2019

1/10
Please reload

Connect

  • White LinkedIn Icon
  • Twitter Clean
  • Salesforce Whizz

© 2020 by Mhlangano Khumalo 

All rights reserved