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. 




Code Repo:










Please reload

Follow Me
Please reload

Search By Tags
Please reload

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

Data Visualization with Chart.JS in Lightning Components

October 3, 2019

Please reload


  • White LinkedIn Icon
  • Twitter Clean
  • Salesforce Whizz

© 2020 by Mhlangano Khumalo 

All rights reserved