Skip to content

Releases: janantala/speech-synthesis

0.4.0

21 May 22:27
Compare
Choose a tag to compare

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

10 Mar 20:34
Compare
Choose a tag to compare

Features

  • Enhance splitting text by delimeters #10

Split long text by multiple delimeters like ., ,, (space) and then hard split.
This will enhance user experience due to natural pause between audio playback.

0.3.2

03 Mar 14:22
Compare
Choose a tag to compare

Fixes

  • Split long words

Google translate limit is 100 characters, if the word is longer there is a network error.
Long words need to be too splitted. #9

0.3.1

03 Mar 10:13
Compare
Choose a tag to compare

Fixes

  • fix punctation network error

Encode text URI Component #7

0.3.0

01 Mar 13:51
Compare
Choose a tag to compare

Features

  • Split long text into multiple requests

Google Translate limit is 100 characters, we need to split longer text and make multiple requests. #5

0.2.1

24 Feb 12:35
Compare
Choose a tag to compare

Feauters

  • identify the polyfill usage
 var u = new window.SpeechSynthesisUtterancePolyfill('Hello World');
 u.isPolyfill; // true

 window.speechSynthesisPolyfill.isPolyfill; // true

Fixes

  • lint
    • rename speechSynthesisPolyfill into SpeechSynthesisPolyfill

0.2.0

21 Feb 22:09
Compare
Choose a tag to compare

Features

  • Rename speechSynthesis into speechSynthesisPolyfill and and SpeechSynthesisUtterance into SpeechSynthesisUtterancePolyfill

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

29 Jan 16:16
Compare
Choose a tag to compare

Add

  • SpeechSynthesisUtterancePolyfill
  • speechSynthesisPolyfill

into window object because it is unable to override speechSynthesis in Firefox browser.

0.1.0

29 Jan 15:06
Compare
Choose a tag to compare

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
  • onmark
  • onboundary

SpeechSynthesisEvent Attributes

  • charIndex
  • elapsedTime
  • name

SpeechSynthesisVoice

  • voiceURI
  • name
  • lang
  • localService
  • default

Voice depends on google translate service.

SpeechSynthesisVoiceList

  • length
  • item