Class: WebAudioTextToSpeech

WebAudioTextToSpeech

mmir.env.media.WebAudioTextToSpeech

Members

readonly_basePluginName

Default Value:
  • "audiotts"

private_defaultCtxName

When specifying the implementation file for an Audio Module Context i.e. {"mod": "webAudioTextToSpeech.js", "ctx": CONTEXT} then plugin configuration will be check, if there is an entry for the ctx, i.e. an implementation file name for entry ctx: "webAudioTextToSpeech": { CONTEXT: IMPLEMENTATION_FILE_ENTRY }, Otherwise the plugin configuration's default entry will be used "webAudioTextToSpeech": { CONTEXT: _defaultCtxName }, If no default entry exists, then _defaultImplFile will be used as implementation.
Default Value:
  • "default"

readonly_defaultImplFile

Default implementation for WebAudioTTS: MARY TTS
Default Value:
  • "ttsMary.js"

private_instance

protected_loggermmir.tools.Logger

Will be set when specific implementation is initialized.
See:

protected_pluginName

Will be set/"overwritten" by specific implementation.
See:

privateaudioArrayArray.<AudioImpl>

internal field for list of "sentence audio-object". Used in ttsSentenceArray

bufferSize

number of audio-objects that should be pre-fetched/buffered when in sentence-mode.

privatecommandQueue

command-queue in case TTS is currently in use -> if TTS invoked, but currently not ready: add to queue -> after processing current TTS: process next on queue

protectedcreateAudio

Will be set/"overwritten" by specific implementation.

protecteddestroySynthesizer

Will be set/"overwritten" by specific implementation.

privateEMPTY_SENTENCE

Placeholder for empty text / sentences: no audio will be created for empty text/sentences, but using this placeholder-audio, pause-durations etc will be applied (e.g. during sentence-mode).

protectedgetLanguages

Will be set/"overwritten" by specific implementation.

protectedgetVoices

Will be set/"overwritten" by specific implementation.

protectedinitSynthesizer

Will be set/"overwritten" by specific implementation.

privateisLoading

privateisReady

privateloadIndex

privatepauseDuration

In sentence mode: pause (in milli-seconds) between reading sentences.

privateplayIndex

privatesentenceArrayArray.<String>

internal field for list of (text) sentences to be played. Used in ttsSentenceArray

privatettsMediaAudioImpl

internal field for single-sentence audio-object. Used in ttsSingleSentence

privatevolume

Methods

staticmmir.env.media.WebAudioTextToSpeech.initialize()

private_resetCallbacks()

private_setVolume()

privateaddToCommandQueue()

command-queue
Cancel current synthesis.
See:

privateclearCommandQueue()

command-queue

privatecurrentFailureCallback()

destroySpeech(successCallback, failureCallback)

Destroy the speech synthesizer instance and free up system resources. NOTE: may not be supported by all synthesizer implementations (e.g. if the impl. does not block system resources etc) IMPORTANT: pluins that support destroySpeech() should also support initializeSpeech().
Name Type Description
successCallback function optional callback in case of success:
successCallback(didDestroy: boolean)
in case, the plugin does not support destroySpeech(), successCallback(false) will be invoked
failureCallback function optional callback that will be invoked in case of an error:
failureCallback(error)
See:

privategetLangParam()

getSpeechLanguages()

get list of supported languages for TTS (may not be supported by all plugins).
See:

privategetVoiceParam()

getVoices(options, successCallback, failureCallback)

get list of supported voices for TTS (may not be supported by all plugins).
Name Type Description
options String | VoiceOptions optional OPTIONAL if String, the language code (optionally with country code) for which the voices should be listed. if VoiceOptions: options.language: {String} OPTIONAL the language code options.details: {Boolean} OPTIONAL if TRUE the returned list contains VoiceDetail objects with {name: STRING, language: STRING, gender: "female" | "male" | "unknown"}
successCallback function the success callback: successCallback(Array)
failureCallback function the error callback: failureCallback(err)
See:

initializeSpeech(successCallback, failureCallback)

Re-initialize the speech synthesizer instance: should be called after invoking destroySpeech() (and its success-callback returned true) before continuing to use the synthesizer instance. NOTE: may not be supported by all synthesizer implementations IMPORTANT: pluins that support initializeSpeech() should also support destroySpeech().
Name Type Description
successCallback function optional callback in case of success:
successCallback(didDestroy: boolean)
in case, the plugin does not support initializeSpeech(), successCallback(false) will be invoked
failureCallback function optional callback that will be invoked in case of an error:
failureCallback(error)
See:

privateinitImpl()

privateloadNext()

privateonEndCallback()

privateonReadyCallback()

privateplayNext()

privateplayNextAfterPause()

privateprocessNextInCommandQueue()

command-queue

setTextToSpeechVolume(newValue)

Set the volume for the speech synthesis (text-to-speech).
Name Type Description
newValue Number TODO specify format / range
See:
Deprecated
  • use tts instead

    tts(options, onPlayedCallback, failureCallback, onReadyCallback)

    Synthesizes ("read out loud") text.
    Name Type Description
    options String | Array.<String> | PlainObject optional OPTIONAL if String or Array of Strings synthesizes the text of the String(s).
    For an Array: each entry is interpreted as "sentence"; after each sentence, a short pause is inserted before synthesizing the the next sentence
    for a PlainObject, the following properties should be used:
    {
    			  text: String | String[], text that should be read aloud
    			, pauseDuration: OPTIONAL Number, the length of the pauses between sentences (i.e. for String Arrays) in milliseconds
    			, language: OPTIONAL String, the language for synthesis (if omitted, the current language setting is used)
    			, voice: OPTIONAL String, the voice (language specific) for synthesis; NOTE that the specific available voices depend on the TTS engine
    			, success: OPTIONAL Function, the on-playing-completed callback (see arg onPlayedCallback)
    			, error: OPTIONAL Function, the error callback (see arg failureCallback)
    			, ready: OPTIONAL Function, the audio-ready callback (see arg onReadyCallback)
    		}
    onPlayedCallback function optional OPTIONAL callback that is invoked when the audio of the speech synthesis finished playing:
    onPlayedCallback()

    NOTE: if used in combination with options.success, this argument will supersede the options
    failureCallback function optional OPTIONAL callback that is invoked in case an error occurred:
    failureCallback(error: String | Error)

    NOTE: if used in combination with options.error, this argument will supersede the options
    onReadyCallback function optional OPTIONAL callback that is invoked when audio becomes ready / is starting to play. If, after the first invocation, audio is paused due to preparing the next audio, then the callback will be invoked with false, and then with true (as first argument), when the audio becomes ready again, i.e. the callback signature is:
    onReadyCallback(isReady: Boolean, audio: IAudio)

    NOTE: if used in combination with options.ready, this argument will supersede the options
    See:

    privatettsSentenceArray()

    privatettsSingleSentence()