Releases: janantala/speech-synthesis
Releases · janantala/speech-synthesis
0.4.0
Features
- Native support detection #14
To detect native speech synthesis support use:
window.nativeSpeechSynthesisSupport(); // true, false
We use polyfill only when speech synthesis is not available. To initialize speech synthesis use:
var fallbackSpeechSynthesis = window.getSpeechSynthesis();
var fallbackSpeechSynthesisUtterance = window.getSpeechSynthesisUtterance();
var u = new fallbackSpeechSynthesisUtterance('Hello World');
u.lang = 'en-US';
u.volume = 1.0;
u.rate = 1.0;
u.onend = function(event) { console.log('Finished in ' + event.elapsedTime + ' seconds.'); };
fallbackSpeechSynthesis.speak(u);
0.3.3
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
Features
- Rename
speechSynthesis
intospeechSynthesisPolyfill
and andSpeechSynthesisUtterance
intoSpeechSynthesisUtterancePolyfill
Now you can use speech-synthesis polyfill this way:
// Initialize polyfill
var fallbackSpeechSynthesis = window.speechSynthesis || window.speechSynthesisPolyfill;
var fallbackSpeechSynthesisUtterance = window.SpeechSynthesisUtterance || window.SpeechSynthesisUtterancePolyfill;
var u = new fallbackSpeechSynthesisUtterance('Hello World');
u.lang = 'en-US';
u.volume = 1.0;
u.rate = 1.0;
u.onend = function(event) { console.log('Finished in ' + event.elapsedTime + ' seconds.'); };
fallbackSpeechSynthesis.speak(u);
0.1.1
0.1.0
Usage
var u = new SpeechSynthesisUtterance('Hello World');
u.lang = 'en-US';
u.volume = 1.0;
u.rate = 1.0;
u.onend = function(event) { console.log('Finished in ' + event.elapsedTime + ' seconds.'); };
speechSynthesis.speak(u);
CORS proxy server
u.corsProxyServer = 'http://www.corsproxy.com/';
Supported attributes and methods
SpeechSynthesis Attributes
- pending
- speaking
- paused
SpeechSynthesis Methods
- speak()
- cancel()
- pause()
- resume()
getVoices()
SpeechSynthesisUtterance Attributes
- text
- lang
voiceURI- volume
- rate
pitch
SpeechSynthesisUtterance Events
- onstart
- onend
- onerror
- onpause
- onresume
onmarkonboundary
SpeechSynthesisEvent Attributes
charIndex- elapsedTime
name
SpeechSynthesisVoice
voiceURInamelanglocalServicedefault
Voice depends on google translate service.
SpeechSynthesisVoiceList
lengthitem