Skip to content

Simple webkitSpeechRecognition wrapper class. (Google Chrome ONLY!)

Notifications You must be signed in to change notification settings

dhodvogner/speechJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

speechJS

Simple webkitSpeechRecognition wrapper class. (Google Chrome ONLY!)

Usage:

Create new instance:

var sr = new SpeechRecognition();

Add event handler:

sr.on([Name of event],  function() {});

Set options

sr.set([option_name], [value]);

or

sr.set({
	[option_name] : [value],
	[option_name] : [value]
});

Start:

sr.start();

Stop:

sr.stop();

Options:

Events:

  • "starting" : Fired when user starting speech recognition.
  • "started" : Fired when speech recognition is started.
  • "stopping" : Fired when user stopping speech recognition.
  • "stopped" : Fired when speech recogniton is stopped.
  • "optionschanged" : Fired when user change speech recognition's settings.
  • "error" : Fired when an error occurs.
  • "result" : Fired when speech recognition got results.

Handle Error & Result events

Example:

sr.on("error", function(e) {
	console.log("[SpeechRecognition]", "Error:", e);
});

sr.on("result", function(evt) {
	console.log("[SpeechRecognition]", "Result:", evt);
	
	for (var i = evt.resultIndex; i < evt.results.length; ++i) {
	  if (evt.results[i].isFinal) {
		output.value += evt.results[i][0].transcript +" | ";
	  } else {
		//evt.results[i][0].transcript; <-- Not fully recognized (alias: interim script)!
	  }
	}
	
});

About

Simple webkitSpeechRecognition wrapper class. (Google Chrome ONLY!)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published