Some objects that will simplify the usage of web speech API. Run "Gulp build" for a concatenated version.
new Speaker(content);
Creates a new speaker instance.
content (String)
String that will be synthesized.
There is an issue with long strings. It is advised not to put strings longer than 250 characters in the constructor.
Declarations are automatically cut in punctuation marks so whole statement can be longer.
It applies only to very log sentences without any dots, questionmarks or exclamation mark.
speaker.playing (Boolean)
Informs if player is currently synthesizing. True, also when syntesis is paused. (Get only)
speaker.paused (Boolean)
Informs if players is currently paused. (Get only)
speaker.synth (window.speechSynthesis)
Grants access to instance of speech synthesiser object.
speaker.start()
Starts synthesis based on string given to constructor.
speaker.pause()
Pauses the player.
speaker.resume()
Resumes the player, at the point it was paused
speaker.stop()
Stops the synthesis. When it is started again, it will start the synthesis at the begining of the string.
speaker.onStart
Fires when synthesis starts.
speaker.onPause
Fires when synthesis is paused.
speaker.onResume
Fires when synthesis is resumed (after pause).
speaker.onEnd
Fires when synthesis ends.
new Command(orders, callback);
Creates an command instance. Takes an array of orders and a callback that will be called with those orders.
orders (Array of Strings)
List of strings. When an order is recognized, callback will be called.
callback (Function)
Function that will be called after an order recognition.
new Reciever(language, commandList);
Creates a listener instance.
language (String)
Language in wich the speech sample will be provided in BCP 47 format, e.g. "pl" for polish, "eng" for english.
commandList (Array of Commands)
An array of command objects, which methods we want to call.
reciever.recording(Boolean)
Informs if reciever is actually recording. (Get only)
reciever.continuous(Boolean)
Informs if reciever is in continuous mode (default False).
reciever.recognition (SpeechRecognition)
Grants access to the "recogniser" object.
reciever.start
Starts recognition.
reciever.stop
Stops recognition.
speaker.onStart
Fires when recognition starts.
speaker.onEnd
Fires when recognition ends.