Added docblocks

This commit is contained in:
Dennis Eichhorn 2017-08-27 21:55:49 +02:00
parent ee6685cfa6
commit 92cae1ea2e
2 changed files with 90 additions and 0 deletions

View File

@ -33,6 +33,15 @@
this.voice = this.voices[0];
};
/**
* Read text.
*
* @param {string} text Text to read
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.ReadManager.prototype.read = function(text)
{
let utter = new SpeechSynthesisUtterance(text);
@ -43,21 +52,55 @@
window.speechSynthesis.speak(utter);
};
/**
* Set Language.
*
* @param {string} lang Language id (e.g. en-US)
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.ReadManager.prototype.setLanguage = function(lang)
{
this.lang = lang;
};
/**
* Set pitch.
*
* @param {int} pitch Pitch
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.ReadManager.prototype.setPitch = function(pitch)
{
this.pitch = pitch;
};
/**
* Set rate.
*
* @param {int} rate Rate
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.ReadManager.prototype.setRate = function(rate)
{
this.rate = rate;
};
/**
* Get supported voices.
*
* @return {array}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.ReadManager.prototype.getVoices = function()
{
return this.voices;

View File

@ -32,6 +32,13 @@
this.lang = typeof lang === 'undefined' ? 'en-US' : lang;
};
/**
* Setup or re-initialize voice manager.
*
* @method
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.VoiceManager.prototype.setup = function()
{
const self = this;
@ -69,27 +76,67 @@
}
};
/**
* Create commands/grammar string from commands
*
* @return {string}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.VoiceManager.prototype.getCommandsString = function()
{
return '#JSGF V1.0; grammar phrase; public <phrase> = ' + Object.keys(this.commands).join(' | ') + ' ;';
};
/**
* Set language
*
* @param {string} lang Language code (e.g. en-US)
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.VoiceManager.prototype.setLanguage = function(lang)
{
// todo: eventually restart
this.recognition.lang = lang;
};
/**
* Add command/grammar and callback.
*
* @param {string} command Command id
* @param {Callback} callback Callback for command
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.VoiceManager.prototype.add = function(command, callback)
{
this.commands[command] = callback;
};
/**
* Start voice listener.
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.VoiceManager.prototype.start = function()
{
this.recognition.start();
};
/**
* Stop voice listener.
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.UI.Input.Voice.VoiceManager.prototype.stop = function()
{
this.recognition.stop();