JavaScript
Imal Perera  

HTML5 Speech Recognition, Converting Voice to Text

Spread the love

Speech Recognition is now coming in built in browsers!! Chrome is the first browser to implement Web Speech Api’s SpeechRecognition but it is little complicated for a beginner so I thought why shouldn’t I give a try to simplify things by writing a library so that everyone can easily use. With that though I was able to create the version one of the SpeechToTextJs Library. 

Here is a sample code on how to use it 

 

 


      var speecht2text = new SpeechToText(function(){
    			speecht2text.setIsContinous(true);
    			speecht2text.setAllowInterimResults(true);
    			speecht2text.setMaxAlternatives(20);

    			var lang = speecht2text.getAllSupportedLanguages();
    			speecht2text.setLanguage((lang[0]).key);  // english

    			speecht2text.start();

    			speecht2text.onEnd(function () {
    				alert(speecht2text.getText());
    			});

    			setTimeout(function(){
    				speecht2text.stop();
    			},5000);
    		},function () {
    			alert("Browser Not Supported");
    		});

Leave A Comment