From 1bac935f4f7422dfc78716241e6dcb5a20177625 Mon Sep 17 00:00:00 2001 From: Jan Antala Date: Mon, 3 Mar 2014 15:20:26 +0100 Subject: [PATCH] chore: v0.3.2 --- README.md | 2 +- bower.json | 2 +- package.json | 2 +- polyfill.min.js | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ee5aba3..1c06248 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# speech-synthesis v0.3.1 [![Build Status](https://travis-ci.org/janantala/speech-synthesis.png?branch=master)](https://travis-ci.org/janantala/speech-synthesis) +# speech-synthesis v0.3.2 [![Build Status](https://travis-ci.org/janantala/speech-synthesis.png?branch=master)](https://travis-ci.org/janantala/speech-synthesis) Speech Synthesis polyfill based on Google Translate service. Polyfill downloads audio from Google Translate server using [CORS](http://caniuse.com/#feat=cors) and plays it using [audio](http://caniuse.com/#feat=audio) element. diff --git a/bower.json b/bower.json index 940472e..4a89eed 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "speech-synthesis", - "version": "0.3.1", + "version": "0.3.2", "description": "Speech Synthesis polyfill", "keywords": ["speech", "synthesis", "polyfill"], "authors": ["Jan Antala "], diff --git a/package.json b/package.json index 70abb6e..9b56c5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "speech-synthesis", - "version": "0.3.1", + "version": "0.3.2", "description": "Speech Synthesis polyfill", "keywords": ["speech", "synthesis", "polyfill"], "authors": ["Jan Antala "], diff --git a/polyfill.min.js b/polyfill.min.js index fe85a4e..58f05c6 100644 --- a/polyfill.min.js +++ b/polyfill.min.js @@ -1,7 +1,7 @@ /*! - * speech-synthesis v0.3.1 + * speech-synthesis v0.3.2 * The MIT License * Copyright (c) 2014 Jan Antala */ -!function(e,n){"use strict";var t=function(e){this.isPolyfill=!0,this.text=e||"",this.lang=n.documentElement.lang||"en-US",this.volume=1,this.rate=1,this.voiceURI="native",this.pitch=1,this.onstart=void 0,this.onend=void 0,this.onerror=void 0,this.onpause=void 0,this.onresume=void 0,this.onmark=void 0,this.onboundary=void 0,this.corsProxyServer="http://www.corsproxy.com/";var t,i,o=this,s={charIndex:void 0,elapsedTime:void 0,name:void 0},r=function(){i=(new Date).getTime(),s.elapsedTime=(i-(t||i))/1e3},a=function(e,n,t){return[e,"translate.google.com/translate_tts?ie=UTF-8&q=",encodeURIComponent(n),"&tl=",t].join("")};return this._initAudio=function(){var e=[];o._ended=!1;var n=new Audio;n.addEventListener("play",function(){r(),t?o.onresume&&o.onresume(s):(t=(new Date).getTime(),o.onstart&&o.onstart(s))},!1),n.addEventListener("ended",function(){if(e.length){var t=a(o.corsProxyServer,e.shift(),o.lang);n.src=t,n.play()}else r(),o._ended=!0,o.onend&&o.onend(s)},!1),n.addEventListener("error",function(){r(),o._ended=!0,o.onerror&&o.onerror(s)},!1),n.addEventListener("pause",function(){o._ended||(r(),o.onpause&&o.onpause(s))},!1);var i=100;if(o.text.length>i){for(var d="",u=o.text.split(" "),c=0;c0&&e.push(d),d=p)}d&&e.push(d)}else e.push(o.text);var l=a(o.corsProxyServer,e.shift(),o.lang);return n.src=l,n.volume=o.volume,n.playbackRate=o.rate,n},this},i=function(){this.isPolyfill=!0,this.pending=!1,this.speaking=!1,this.paused=!1;var e=this,n=new Audio,t=[],i=function(t){var i=t.shift();e.speaking=!1,e.pending=t.length?!0:!1,i&&(n=i._initAudio(),o(n,i),d())},o=function(e,n){e.addEventListener("play",function(){},!1),e.addEventListener("ended",function(){n._ended&&i(t)},!1),e.addEventListener("error",function(){i(t)},!1),e.addEventListener("pause",function(){},!1)},s=function(n){e.pending=!0,t.push(n),e.speaking||e.paused||i(t)},r=function(){n.src="",n=void 0,n=new Audio,e.pending=!1,e.speaking=!1,e.paused=!1,t=[],i(t)},a=function(){n.pause(),e.speaking=!1,e.paused=!0},d=function(){n.src?(n.play(),e.speaking=!0):i(t),e.paused=!1},u=function(){return[]};return{isPolyfill:!0,pending:e.pending,speaking:e.speaking,paused:e.paused,speak:function(e){s(e)},cancel:function(){r()},pause:function(){a()},resume:function(){d()},getVoices:function(){u()}}};e.SpeechSynthesisUtterancePolyfill=t,e.speechSynthesisPolyfill=new i}(window,document); \ No newline at end of file +!function(e,n){"use strict";var t=function(e){this.isPolyfill=!0,this.text=e||"",this.lang=n.documentElement.lang||"en-US",this.volume=1,this.rate=1,this.voiceURI="native",this.pitch=1,this.onstart=void 0,this.onend=void 0,this.onerror=void 0,this.onpause=void 0,this.onresume=void 0,this.onmark=void 0,this.onboundary=void 0,this.corsProxyServer="http://www.corsproxy.com/";var t,i,s=this,o={charIndex:void 0,elapsedTime:void 0,name:void 0},r=function(){i=(new Date).getTime(),o.elapsedTime=(i-(t||i))/1e3},a=function(e,n,t){return[e,"translate.google.com/translate_tts?ie=UTF-8&q=",encodeURIComponent(n),"&tl=",t].join("")};return this._initAudio=function(){var e=[];s._ended=!1;var n=new Audio;n.addEventListener("play",function(){r(),t?s.onresume&&s.onresume(o):(t=(new Date).getTime(),s.onstart&&s.onstart(o))},!1),n.addEventListener("ended",function(){if(e.length){var t=a(s.corsProxyServer,e.shift(),s.lang);n.src=t,n.play()}else r(),s._ended=!0,s.onend&&s.onend(o)},!1),n.addEventListener("error",function(){r(),s._ended=!0,s.onerror&&s.onerror(o)},!1),n.addEventListener("pause",function(){s._ended||(r(),s.onpause&&s.onpause(o))},!1);var i=100;if(s.text.length>i){for(var d="",u=s.text.split(" "),c=0;c0&&(e.push(d),d=h),h.length>i){for(var l=new RegExp(".{1,"+i+"}","g"),p=h.match(l);p.length>0;)e.push(p.shift());d=""}}d.length>0&&e.push(d)}else e.push(s.text);var f=a(s.corsProxyServer,e.shift(),s.lang);return n.src=f,n.volume=s.volume,n.playbackRate=s.rate,n},this},i=function(){this.isPolyfill=!0,this.pending=!1,this.speaking=!1,this.paused=!1;var e=this,n=new Audio,t=[],i=function(t){var i=t.shift();e.speaking=!1,e.pending=t.length?!0:!1,i&&(n=i._initAudio(),s(n,i),d())},s=function(e,n){e.addEventListener("play",function(){},!1),e.addEventListener("ended",function(){n._ended&&i(t)},!1),e.addEventListener("error",function(){i(t)},!1),e.addEventListener("pause",function(){},!1)},o=function(n){e.pending=!0,t.push(n),e.speaking||e.paused||i(t)},r=function(){n.src="",n=void 0,n=new Audio,e.pending=!1,e.speaking=!1,e.paused=!1,t=[],i(t)},a=function(){n.pause(),e.speaking=!1,e.paused=!0},d=function(){n.src?(n.play(),e.speaking=!0):i(t),e.paused=!1},u=function(){return[]};return{isPolyfill:!0,pending:e.pending,speaking:e.speaking,paused:e.paused,speak:function(e){o(e)},cancel:function(){r()},pause:function(){a()},resume:function(){d()},getVoices:function(){u()}}};e.SpeechSynthesisUtterancePolyfill=t,e.speechSynthesisPolyfill=new i}(window,document); \ No newline at end of file