Add Speech Recognition to your Website, only for Google Chrome (PC and MAC)

Published on : April 27, 2026

Author:

Category: Uncategorized


You can add Speech recognition to your website to do contact, search and creating note more user friendly.

For example, say “How to add custom fields to Mailchimp listing” .

To do this, some requirements are –

  1. Google Chrome
  2. SSL enabled site (https://)
  3. Microphone

 

Just simply add mic icon to your current input field or create an input fields as below image –

microphone icon

Here is sample html code-

<form id=”speech_form” action=”” method=”get”><input name=”your_email_address” type=”text” placeholder=”Your Email Address” /> <img src=”images/button.gif” /></form>

 

Also here is sample javascript code-


var patience = 30;
function startSpeech() {	
    if (window.hasOwnProperty('webkitSpeechRecognition')) {
    
        var recognition = new webkitSpeechRecognition();
    
        recognition.continuous = true;
        recognition.interimResults = false;
    
        recognition.lang = "en-US"; // Dynamic Language
        recognition.start();
        
        function restartTimer() {
            timeout = setTimeout(function() {
                recognition.stop();
            }, patience * 1000);
        }
        
         recognition.onstart = function() {
            // do somthings
            restartTimer();
        };
        
        recognition.onend = function() {
            // do somthings
        };
    
        recognition.onresult = function(e) {
            document.getElementById('transcript').value = e.results[0][0].transcript;
            recognition.stop();
            document.getElementById('speech_form').submit();
        };
        
        recognition.onerror = function(e) {
            recognition.stop();
        }
    
    }
}