JavaScript based web functions to manage the text-to-voice/text-to-speech browser api. It works creating fragments of the original text and receiving some parameters like language, rate and pitch.
Example file that imports the tv2.js
and uses it to read the content of a textarea input.
The utility functions are listed below.
Reads text, has no return. Language codes references in: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
text
: string (mandatory)lang
: string (language code, depends of the languages available in each client web browser)rate
: number (speed of the reader, default is 0.9, normal is 1)pitch
: number (pitch of the reader, default is 1, normal is 1)
textToVoice(
(text = "some string"),
(lang = "es-MX"),
(rate = 0.9),
(pitch = 1.2)
);
Stops the reader, has no return.
stopTextToVoice();
Receives a string and returns an array of chunks of the string.
chunksArrayFromText = chunkText("some long text");
Shows in the console the list of voices available in the current client, depending on the browser, os, and pc.
listVoices();
Returns the name of the current client computer OS.
nameOfTheCurrentOS = whichOS();
Returns the name of the current client web browser.
nameOfCurrentBrowser = whichBrowser();
Returns true if the current browser is based on the open project of Chromium.
booleanIfIsChromiumBased = isChromiumBasedBrowser();