utterance

1.1.0 • Public • Published

Utterance

Some objects that will simplify the usage of web speech API. Run "Gulp build" for a concatenated version.

Speaker - Class that handles the speech synthesis.

Constructor

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.

Properties

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.

Methods

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.

Events

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.


Command - Helper class that contains methods we want to run and voice commands assigned to them.

Constructor

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.

Properties

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.

Methods

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.

Events

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.


Command - Helper class that contains methods we want to run and voice commands assigned to them.

Constructor

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.


Reciever - Class responsible for listening and speech recognition.

Konstruktor

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.

Properties

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.

Methods

reciever.start

Starts recognition.

reciever.stop

Stops recognition.

Events

speaker.onStart

Fires when recognition starts.

speaker.onEnd

Fires when recognition ends.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    1
  • 1.0.0
    0

Package Sidebar

Install

npm i utterance

Weekly Downloads

1

Version

1.1.0

License

ISC

Last publish

Collaborators

  • vonbroncel