Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix TTS widget on Internet explorer.

  • Loading branch information...
commit 581af2dce7832c55ea3920dbe74ee12e8c62aacd 1 parent 29f7df4
Szaby Grünwald authored
View
1  lib/ttswidget/index.html
@@ -7,6 +7,7 @@
<link rel="stylesheet" href="ttswidget.css" />
<link rel="stylesheet" href="../jquery/jquery-ui.min.css" />
+ <script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
<script type="text/javascript" src="../jquery/jquery-1.7.1.js"></script>
<script type="text/javascript" src="../jquery/jquery-ui.1.9m5.js"></script>
<script type="text/javascript" src="../underscore-min.js"></script>
View
97 lib/ttswidget/index.html~
@@ -0,0 +1,97 @@
+<html>
+<head>
+ <title>CapKom Wizard</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+
+ <link rel="stylesheet" href="ttswidget.css" />
+ <link rel="stylesheet" href="../jquery/jquery-ui.min.css" />
+
+ <script type="text/javascript" src="../jquery/jquery-1.7.1.js"></script>
+ <script type="text/javascript" src="../jquery/jquery-ui.1.9m5.js"></script>
+ <script type="text/javascript" src="../underscore-min.js"></script>
+ <script type="text/javascript" src="../backbone.js"></script>
+ <script type="text/javascript" src="../jquery/themeswitcher.js"></script>
+ <script type="text/javascript" src="../json-serialization.js"></script>
+
+ <link rel="stylesheet" href="../../css/style.css" />
+ <script type="text/javascript" src="ttswidget.js"></script>
+ <script type="text/javascript">
+ jQuery(document).ready(function(){_.defer(function(){
+ jQuery(".tts").ttswidget({
+ gender: "male"
+ });
+ })});
+ </script>
+
+ <style>
+ section {
+ max-width: 500px;
+ }
+ section div {
+ padding: 14px;
+ }
+ button.ui-button-icon-only .ui-icon {
+ width: 22px;
+ height: 22px;
+ margin-left: -11px;
+ margin-top: -11px;
+ }
+ .ui-icon-speaker {
+ background-image: url(speaker22.png) !important;
+ }
+ </style>
+</head>
+<body>
+ <header>
+ <a href="#"><img class="logo" alt="Capkom Logo" src="../../symbols/Capkom_Logo.gif"/></a>
+ </header>
+ <section>
+ <h1>TTS widget</h1>
+ <h2>Demo</h2>
+ <div class="tts" lang="en">
+ Normally the text content of the element is taken.
+ </div>
+ <div class="tts" tts="This is set as tts attribute of the .tts element.">
+ Except you set the tts argument of the element.
+ </div>
+ <div class="tts" lang="de">
+ Spricht natürlich auch deutsch.
+ </div>
+ <textarea id="tts-test" cols="60" rows="10">
+Test a text
+ </textarea><br/>
+ <select name="lang" id="lang">
+ <option value="en">english</option>
+ <option value="de">deutsch</option>
+ </select>
+ <br/>
+ <select name="gender" id="gender">
+ <option value="male">male</option>
+ <option value="female">female</option>
+ </select>
+ <br/>
+ <button id="ttstest-button">Say</button>
+ </section>
+ <div style="display:none;" id="bgThemeActivator"></div>
+ <script>
+ (function($){
+ $(document).ready(function(){
+ $('#ttstest-button')
+ .button()
+ .click(function(){
+ console.log(123);
+ var span = $('<span>')
+ .attr('tts', $('#tts-test').val())
+ .attr('gender', $('#gender').val())
+ .attr('lang', $('#lang').val());
+ console.log(span);
+ span
+ .ttswidget()
+ .ttswidget('talk')
+ })
+ });
+ })(jQuery);
+ </script>
+</body>
+</html>
View
112 lib/ttswidget/ttswidget.coffee
@@ -13,7 +13,7 @@
# jQuery(".tts").ttswidget({
# gender: "male"
# });
-# This will instantiate buttons for reading the texts. If the DOM element has a
+# This will instantiate buttons for reading the texts. If the DOM element has a
# `tts` attribute, it will be read instead of the text content of the element.
# The `lang` attribute specifies the language of interpretation. If no language
# is defined the default language is used. (see at `options`)
@@ -63,12 +63,66 @@ jQuery.widget "capkom.ttswidget",
@_cleanup()
talk: ->
@prepare()
+ audioSnippet = null
+ if jQuery.browser.msie
+ audioSnippet = """
+ <OBJECT id='playera' height='60' width='230' classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95'>
+ <PARAM NAME='AutoStart' VALUE='True'>
+ <PARAM NAME='Balance' VALUE='False'>
+ <PARAM NAME='DisplaySize' VALUE='True'>
+ <PARAM NAME='Filename' VALUE='#{@_makeLink()}'>
+ <PARAM NAME='Mute' VALUE='False'>
+ <PARAM NAME='SelectionStart' VALUE='False'>
+ <PARAM NAME='SelectionEnd' VALUE='False'>
+ <PARAM NAME='SendPlayStateChangeEvents' VALUE='True'>
+ <PARAM NAME='ShowControls' VALUE='True'>
+ <PARAM NAME='ShowAudioControls' VALUE='True'>
+ <PARAM NAME='ShowDisplay' VALUE='False'>
+ <PARAM NAME='ShowPositionControls' VALUE='False'>
+ <PARAM NAME='Volume' VALUE='1'>
+ <PARAM NAME='AudioStream' VALUE='False'>
+ <PARAM NAME='AutoSize' VALUE='True'>
+ <PARAM NAME='AnimationAtStart' VALUE='False'>
+ <PARAM NAME='AllowScan' VALUE='False'>
+ <PARAM NAME='AllowChangeDisplaySize' VALUE='False'>
+ <PARAM NAME='AutoRewind' VALUE='True'>
+ <PARAM NAME='BaseURL' VALUE=''>
+ <PARAM NAME='BufferingTime' VALUE='5'>
+ <PARAM NAME='CaptioningID' VALUE=''>
+ <PARAM NAME='ClickToPlay' VALUE='True'>
+ <PARAM NAME='CursorType' VALUE='0'>
+ <PARAM NAME='CurrentPosition' VALUE='True'>
+ <PARAM NAME='CurrentMarker' VALUE='True'>
+ <PARAM NAME='DefaultFrame' VALUE='mainframe'>
+ <PARAM NAME='DisplayBackColor' VALUE='True'>
+ <PARAM NAME='DisplayForeColor' VALUE='16777215'>
+ <PARAM NAME='DisplayMode' VALUE='1'>
+ <PARAM NAME='Enabled' VALUE='-1'>
+ <PARAM NAME='EnableContextMenu' VALUE='False'>
+ <PARAM NAME='EnablePositionControls' VALUE='False'>
+ <PARAM NAME='EnableFullScreenControls' VALUE='False'>
+ <PARAM NAME='EnableTracker' VALUE='False'>
+ <PARAM NAME='InvokeURLs' VALUE='False'>
+ <PARAM NAME='Language' VALUE='False'>
+ <PARAM NAME='PlayCount' VALUE='1'>
+ <PARAM NAME='PreviewMode' VALUE='False'>
+ <PARAM NAME='ShowStatusBar' VALUE='False'>
+ <PARAM NAME='TransparentAtStart' VALUE='False'>
+ </OBJECT>
+ """
+ else
+ audioSnippet = """
+ <audio id='ttswidget-audio' controls='controls' style='' src='#{@_makeLink()}'
+ type='audio/mpeg'>Your browser does not support the audio tag.
+ </audio>
+ <img class='spinner' src='#{@options.spinnerUri}'/>
+ """
+
@dialog = jQuery """
<div id='ttswidget-dialog' title='#{@options.dialogTitle}'>
#{@_getText()}
<br/><br/>
- <audio id='ttswidget-audio' onerror='console.error(this)' controls='controls' style='' src='#{@_makeLink()}' type='audio/ogg'>Your browser does not support the audio tag.</audio>
- <img class='spinner' src='#{@options.spinnerUri}'/>
+ #{audioSnippet}
</div>
"""
@dialog.appendTo jQuery("body")
@@ -79,27 +133,33 @@ jQuery.widget "capkom.ttswidget",
, 500
hide: "fade"
width: "500"
- @audioElement = jQuery("#ttswidget-audio")[0]
- @audioElement.onabort = () ->
- console.error attributes
- @audioElement.load()
- @audioElement.play()
- jQuery(@audioElement).bind 'playing', =>
- jQuery(".spinner", @dialog).hide()
- jQuery(@audioElement).bind 'ended', =>
- @dialog.dialog "close"
- setTimeout =>
- @_cleanup()
- , 500
- jQuery(@audioElement).bind 'error', (e) =>
- errorHtml = """
- <br/>
- <div style="color: red">
- <span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>#{@options.errorMsg}
- </div>
- """
- @dialog.append errorHtml
-
+ if jQuery.browser.msie
+ document.playera.attachEvent "EndOfStream", (state) =>
+ @dialog.dialog "close"
+ setTimeout =>
+ @_cleanup()
+ , 500
+ else
+ @audioElement = jQuery("#ttswidget-audio")[0]
+ @audioElement.onabort = () ->
+ console?.error attributes
+ @audioElement.load()
+ @audioElement.play()
+ jQuery(@audioElement).bind 'playing', =>
+ jQuery(".spinner", @dialog).hide()
+ jQuery(@audioElement).bind 'ended', =>
+ @dialog.dialog "close"
+ setTimeout =>
+ @_cleanup()
+ , 500
+ jQuery(@audioElement).bind 'error', (e) =>
+ errorHtml = """
+ <br/>
+ <div style="color: red">
+ <span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>#{@options.errorMsg}
+ </div>
+ """
+ @dialog.append errorHtml
_cleanup: ->
jQuery("#ttswidget-dialog").dialog("destroy").remove()
_getText: ->
@@ -113,7 +173,7 @@ jQuery.widget "capkom.ttswidget",
return @element.attr "gender" if @element.attr "gender"
return @options.gender if @options.gender
preset: (lang="en", gender="male") ->
- presets =
+ presets =
"de-male": [
"LOCALE=de"
"VOICE=bits3"
@@ -131,7 +191,7 @@ jQuery.widget "capkom.ttswidget",
"VOICE=dfki-prudence"
]
res = presets["#{lang}-#{gender}"]
- console.error "There's no TTS preset defined for #{lang} and #{gender}." unless res
+ console?.error "There's no TTS preset defined for #{lang} and #{gender}." unless res
return res or presets["de-female"]
# Internal method for implementing the audio uri.
View
257 lib/ttswidget/ttswidget.coffee~
@@ -0,0 +1,257 @@
+# ttswidget is a jQuery UI widget, creating a Text-To-Seech button at the beginning of a DOM element.
+# Pressing the button will open up a dialog box showing the read text and a player control UI
+# for pausing or stopping the audio.
+# Usage:
+#
+# <div class="tts" lang="en">
+# Normally the text content of the element is taken.
+# </div>
+# <div class="tts" tts="This is set as tts attribute of the .tts element.">
+# Except you set the tts argument of the element.
+# </div>
+#
+# jQuery(".tts").ttswidget({
+# gender: "male"
+# });
+# This will instantiate buttons for reading the texts. If the DOM element has a
+# `tts` attribute, it will be read instead of the text content of the element.
+# The `lang` attribute specifies the language of interpretation. If no language
+# is defined the default language is used. (see at `options`)
+
+jQuery.widget "capkom.ttswidget",
+ # Options:
+ options:
+ # Default language of text interpretaion. This can be overridden by setting
+ # the `lang` attribute of the element.
+ language: "de"
+ # The used backend URI
+ backendUri: "http://dev.iks-project.eu/mary"
+ # Type of the used backend.
+ backendType: "MARY"
+ # UI icon class to be used for the button
+ iconClass: "ui-icon-speaker"
+ # Spinner icon to be shown when still loading
+ spinnerUri: "spinner.gif"
+ # Dialog title
+ dialogTitle: "TTS widget"
+ # Default text to be read in case no text is found
+ defaultText: "No text found"
+ # The button title to be set. This is not shown but if a screen reader
+ # would read it, it is shown.
+ buttonLabel: "Speak"
+ # The error message when something goes wrong loading the audio.
+ errorMsg: "Error loading audio."
+
+ _create: ->
+ # Add button to the element
+ @button = jQuery "<button class='tts-button'>#{@options.buttonLabel}</button>"
+ @button.prependTo @element
+ @button.button
+ text: false
+ icons:
+ primary: @options.iconClass
+ @button.click (e) =>
+ e.preventDefault()
+ @talk()
+ false
+ _destroy: ->
+ @_cleanup()
+ jQuery(@button)
+ .button("destroy")
+ .remove()
+ prepare: ->
+ @_cleanup()
+ talk: ->
+ @prepare()
+ audioSnippet = null
+ if jQuery.browser.msie
+ audioSnippet = """
+ <OBJECT id='playera' height='60' width='230' classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95'>
+ <PARAM NAME='AutoStart' VALUE='True'>
+ <PARAM NAME='Balance' VALUE='False'>
+ <PARAM NAME='DisplaySize' VALUE='True'>
+ <PARAM NAME='Filename' VALUE='#{@_makeLink()}'>
+ <PARAM NAME='Mute' VALUE='False'>
+ <PARAM NAME='SelectionStart' VALUE='False'>
+ <PARAM NAME='SelectionEnd' VALUE='False'>
+ <PARAM NAME='SendPlayStateChangeEvents' VALUE='True'>
+ <PARAM NAME='ShowControls' VALUE='True'>
+ <PARAM NAME='ShowAudioControls' VALUE='True'>
+ <PARAM NAME='ShowDisplay' VALUE='False'>
+ <PARAM NAME='ShowPositionControls' VALUE='False'>
+ <PARAM NAME='Volume' VALUE='1'>
+ <PARAM NAME='AudioStream' VALUE='False'>
+ <PARAM NAME='AutoSize' VALUE='True'>
+ <PARAM NAME='AnimationAtStart' VALUE='False'>
+ <PARAM NAME='AllowScan' VALUE='False'>
+ <PARAM NAME='AllowChangeDisplaySize' VALUE='False'>
+ <PARAM NAME='AutoRewind' VALUE='True'>
+ <PARAM NAME='BaseURL' VALUE=''>
+ <PARAM NAME='BufferingTime' VALUE='5'>
+ <PARAM NAME='CaptioningID' VALUE=''>
+ <PARAM NAME='ClickToPlay' VALUE='True'>
+ <PARAM NAME='CursorType' VALUE='0'>
+ <PARAM NAME='CurrentPosition' VALUE='True'>
+ <PARAM NAME='CurrentMarker' VALUE='True'>
+ <PARAM NAME='DefaultFrame' VALUE='mainframe'>
+ <PARAM NAME='DisplayBackColor' VALUE='True'>
+ <PARAM NAME='DisplayForeColor' VALUE='16777215'>
+ <PARAM NAME='DisplayMode' VALUE='1'>
+ <PARAM NAME='Enabled' VALUE='-1'>
+ <PARAM NAME='EnableContextMenu' VALUE='False'>
+ <PARAM NAME='EnablePositionControls' VALUE='False'>
+ <PARAM NAME='EnableFullScreenControls' VALUE='False'>
+ <PARAM NAME='EnableTracker' VALUE='False'>
+ <PARAM NAME='InvokeURLs' VALUE='False'>
+ <PARAM NAME='Language' VALUE='False'>
+ <PARAM NAME='PlayCount' VALUE='1'>
+ <PARAM NAME='PreviewMode' VALUE='False'>
+ <PARAM NAME='ShowStatusBar' VALUE='False'>
+ <PARAM NAME='TransparentAtStart' VALUE='False'>
+ </OBJECT>
+ """
+ else
+ audioSnippet = """
+ <audio id='ttswidget-audio' controls='controls' style='' src='#{@_makeLink()}'
+ type='audio/mpeg'>Your browser does not support the audio tag.
+ </audio>
+ <img class='spinner' src='#{@options.spinnerUri}'/>
+ """
+
+ @dialog = jQuery """
+ <div id='ttswidget-dialog' title='#{@options.dialogTitle}'>
+ #{@_getText()}
+ <br/><br/>
+ #{audioSnippet}
+ </div>
+ """
+ @dialog.appendTo jQuery("body")
+ @dialog.dialog
+ close: =>
+ setTimeout =>
+ @_cleanup()
+ , 500
+ hide: "fade"
+ width: "500"
+ if jQuery.browser.msie
+ document.playera.attachEvent "EndOfStream", (state) =>
+ @dialog.dialog "close"
+ setTimeout =>
+ @_cleanup()
+ , 500
+ else
+ @audioElement = jQuery("#ttswidget-audio")[0]
+ @audioElement.onabort = () ->
+ console?.error attributes
+ @audioElement.load()
+ @audioElement.play()
+ jQuery(@audioElement).bind 'playing', =>
+ jQuery(".spinner", @dialog).hide()
+ jQuery(@audioElement).bind 'ended', =>
+ @dialog.dialog "close"
+ setTimeout =>
+ @_cleanup()
+ , 500
+ jQuery(@audioElement).bind 'error', (e) =>
+ errorHtml = """
+ <br/>
+ <div style="color: red">
+ <span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>#{@options.errorMsg}
+ </div>
+ """
+ @dialog.append errorHtml
+ _cleanup: ->
+ jQuery("#ttswidget-dialog").dialog("destroy").remove()
+ _getText: ->
+ return @element.attr "tts" if @element.attr "tts"
+ return @element.not(@button).text().replace("#{@options.buttonLabel}", "") if @element.text()
+ return @options.defaultText
+ _getLang: ->
+ return @element.attr "lang" if @element.attr "lang"
+ return @options.lang if @options.lang
+ _getGender: ->
+ return @element.attr "gender" if @element.attr "gender"
+ return @options.gender if @options.gender
+ preset: (lang="en", gender="male") ->
+ presets =
+ "de-male": [
+ "LOCALE=de"
+ "VOICE=bits3"
+ ]
+ "de-female": [
+ "LOCALE=de"
+ "VOICE=bits1-hsmm"
+ ]
+ "en-male": [
+ "LOCALE=en_GB"
+ "VOICE=dfki-spike"
+ ]
+ "en-female": [
+ "LOCALE=en_GB"
+ "VOICE=dfki-prudence"
+ ]
+ res = presets["#{lang}-#{gender}"]
+ console.error "There's no TTS preset defined for #{lang} and #{gender}." unless res
+ return res or presets["de-female"]
+
+ # Internal method for implementing the audio uri.
+ _makeLink: () ->
+ _encodeURI = (str) ->
+ encodeURI(str).replace /'/g, "%27"
+ text = @_getText()
+ uri = @options.backendUri + "/process?"
+ params = @preset(@_getLang(), @_getGender())
+ .concat [
+ "INPUT_TYPE=TEXT&OUTPUT_TYPE=AUDIO&INPUT_TEXT=#{_encodeURI text}"
+ "OUTPUT_TEXT="
+ "effect_Volume_selected="
+ "effect_Volume_parameters=" + encodeURI "amount:2.0;"
+ "effect_Volume_default=Default"
+ "effect_Volume_help=Help"
+ "effect_TractScaler_selected="
+ "effect_TractScaler_parameters" + encodeURI "amount:1.5;"
+ "effect_TractScaler_default=Default"
+ "effect_TractScaler_help=Help"
+ "effect_F0Scale_selected="
+ "effect_F0Scale_parameters=" + encodeURI "f0Scale:2.0;"
+ "effect_F0Scale_default=Default"
+ "effect_F0Scale_help=Help"
+ "effect_F0Add_selected="
+ "effect_F0Add_parameters=" + encodeURI "f0Add:50.0;"
+ "effect_F0Add_default=Default"
+ "effect_F0Add_help=Help"
+ "effect_Rate_selected="
+ "effect_Rate_parameters=" + encodeURI "durScale:1.5;"
+ "effect_Rate_default=Default"
+ "effect_Rate_help=Help"
+ "effect_Robot_selected="
+ "effect_Robot_parameters=" + encodeURI "amount:100.0;"
+ "effect_Robot_default=Default"
+ "effect_Robot_help=Help"
+ "effect_Whisper_selected="
+ "effect_Whisper_parameters=" + encodeURI "amount:100.0;"
+ "effect_Whisper_default=Default"
+ "effect_Whisper_help=Help"
+ "effect_Stadium_selected="
+ "effect_Stadium_parameters=" + encodeURI "amount:100.0"
+ "effect_Stadium_default=Default"
+ "effect_Stadium_help=Help"
+ "effect_Chorus_selected="
+ "effect_Chorus_parameters=" + encodeURI "delay1:466;amp1:0.54;delay2:600;amp2:-0.10;delay3:250;amp3:0.30"
+ "effect_Chorus_default=Default"
+ "effect_Chorus_help=Help"
+ "effect_FIRFilter_selected="
+ "effect_FIRFilter_parameters=" + encodeURI "type:3;fc1:500.0;fc2:2000.0"
+ "effect_FIRFilter_default=Default"
+ "effect_FIRFilter_help=Help"
+ "effect_JetPilot_selected="
+ "effect_JetPilot_parameters="
+ "effect_JetPilot_default=Default"
+ "effect_JetPilot_help=Help"
+ "HELP_TEXT="
+ "VOICE_SELECTIONS=bits3%20de%20male%20unitselection%20general"
+ "AUDIO_OUT=WAVE_FILE"
+ "AUDIO=WAVE_FILE"
+ ]
+ res = uri + params.join '&'
+ res
View
93 lib/ttswidget/ttswidget.js
@@ -1,3 +1,4 @@
+// Generated by CoffeeScript 1.3.1
(function() {
jQuery.widget("capkom.ttswidget", {
@@ -36,9 +37,16 @@
return this._cleanup();
},
talk: function() {
- var _this = this;
+ var audioSnippet,
+ _this = this;
this.prepare();
- this.dialog = jQuery("<div id='ttswidget-dialog' title='" + this.options.dialogTitle + "'>\n " + (this._getText()) + "\n <br/><br/>\n <audio id='ttswidget-audio' onerror='console.error(this)' controls='controls' style='' src='" + (this._makeLink()) + "' type='audio/ogg'>Your browser does not support the audio tag.</audio>\n <img class='spinner' src='" + this.options.spinnerUri + "'/>\n</div>");
+ audioSnippet = null;
+ if (jQuery.browser.msie) {
+ audioSnippet = "<OBJECT id='playera' height='60' width='230' classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95'>\n <PARAM NAME='AutoStart' VALUE='True'>\n <PARAM NAME='Balance' VALUE='False'>\n <PARAM NAME='DisplaySize' VALUE='True'>\n <PARAM NAME='Filename' VALUE='" + (this._makeLink()) + "'>\n <PARAM NAME='Mute' VALUE='False'>\n <PARAM NAME='SelectionStart' VALUE='False'>\n <PARAM NAME='SelectionEnd' VALUE='False'>\n <PARAM NAME='SendPlayStateChangeEvents' VALUE='True'>\n <PARAM NAME='ShowControls' VALUE='True'>\n <PARAM NAME='ShowAudioControls' VALUE='True'>\n <PARAM NAME='ShowDisplay' VALUE='False'>\n <PARAM NAME='ShowPositionControls' VALUE='False'>\n <PARAM NAME='Volume' VALUE='1'>\n <PARAM NAME='AudioStream' VALUE='False'>\n <PARAM NAME='AutoSize' VALUE='True'>\n <PARAM NAME='AnimationAtStart' VALUE='False'>\n <PARAM NAME='AllowScan' VALUE='False'>\n <PARAM NAME='AllowChangeDisplaySize' VALUE='False'>\n <PARAM NAME='AutoRewind' VALUE='True'>\n <PARAM NAME='BaseURL' VALUE=''>\n <PARAM NAME='BufferingTime' VALUE='5'>\n <PARAM NAME='CaptioningID' VALUE=''>\n <PARAM NAME='ClickToPlay' VALUE='True'>\n <PARAM NAME='CursorType' VALUE='0'>\n <PARAM NAME='CurrentPosition' VALUE='True'>\n <PARAM NAME='CurrentMarker' VALUE='True'>\n <PARAM NAME='DefaultFrame' VALUE='mainframe'>\n <PARAM NAME='DisplayBackColor' VALUE='True'>\n <PARAM NAME='DisplayForeColor' VALUE='16777215'>\n <PARAM NAME='DisplayMode' VALUE='1'>\n <PARAM NAME='Enabled' VALUE='-1'>\n <PARAM NAME='EnableContextMenu' VALUE='False'>\n <PARAM NAME='EnablePositionControls' VALUE='False'>\n <PARAM NAME='EnableFullScreenControls' VALUE='False'>\n <PARAM NAME='EnableTracker' VALUE='False'>\n <PARAM NAME='InvokeURLs' VALUE='False'>\n <PARAM NAME='Language' VALUE='False'>\n <PARAM NAME='PlayCount' VALUE='1'>\n <PARAM NAME='PreviewMode' VALUE='False'>\n <PARAM NAME='ShowStatusBar' VALUE='False'>\n <PARAM NAME='TransparentAtStart' VALUE='False'>\n</OBJECT>";
+ } else {
+ audioSnippet = "<audio id='ttswidget-audio' controls='controls' style='' src='" + (this._makeLink()) + "'\n type='audio/mpeg'>Your browser does not support the audio tag.\n</audio>\n<img class='spinner' src='" + this.options.spinnerUri + "'/>";
+ }
+ this.dialog = jQuery("<div id='ttswidget-dialog' title='" + this.options.dialogTitle + "'>\n " + (this._getText()) + "\n <br/><br/>\n " + audioSnippet + "\n</div>");
this.dialog.appendTo(jQuery("body"));
this.dialog.dialog({
close: function() {
@@ -49,49 +57,72 @@
hide: "fade",
width: "500"
});
- this.audioElement = jQuery("#ttswidget-audio")[0];
- this.audioElement.onabort = function() {
- return console.error(attributes);
- };
- this.audioElement.load();
- this.audioElement.play();
- jQuery(this.audioElement).bind('playing', function() {
- return jQuery(".spinner", _this.dialog).hide();
- });
- jQuery(this.audioElement).bind('ended', function() {
- _this.dialog.dialog("close");
- return setTimeout(function() {
- return _this._cleanup();
- }, 500);
- });
- return jQuery(this.audioElement).bind('error', function(e) {
- var errorHtml;
- errorHtml = "<br/>\n<div style=\"color: red\">\n <span class=\"ui-icon ui-icon-alert\" style=\"float:left; margin:0 7px 20px 0;\"></span>" + _this.options.errorMsg + "\n</div>";
- return _this.dialog.append(errorHtml);
- });
+ if (jQuery.browser.msie) {
+ return document.playera.attachEvent("EndOfStream", function(state) {
+ _this.dialog.dialog("close");
+ return setTimeout(function() {
+ return _this._cleanup();
+ }, 500);
+ });
+ } else {
+ this.audioElement = jQuery("#ttswidget-audio")[0];
+ this.audioElement.onabort = function() {
+ return typeof console !== "undefined" && console !== null ? console.error(attributes) : void 0;
+ };
+ this.audioElement.load();
+ this.audioElement.play();
+ jQuery(this.audioElement).bind('playing', function() {
+ return jQuery(".spinner", _this.dialog).hide();
+ });
+ jQuery(this.audioElement).bind('ended', function() {
+ _this.dialog.dialog("close");
+ return setTimeout(function() {
+ return _this._cleanup();
+ }, 500);
+ });
+ return jQuery(this.audioElement).bind('error', function(e) {
+ var errorHtml;
+ errorHtml = "<br/>\n<div style=\"color: red\">\n <span class=\"ui-icon ui-icon-alert\" style=\"float:left; margin:0 7px 20px 0;\"></span>" + _this.options.errorMsg + "\n</div>";
+ return _this.dialog.append(errorHtml);
+ });
+ }
},
_cleanup: function() {
return jQuery("#ttswidget-dialog").dialog("destroy").remove();
},
_getText: function() {
- if (this.element.attr("tts")) return this.element.attr("tts");
+ if (this.element.attr("tts")) {
+ return this.element.attr("tts");
+ }
if (this.element.text()) {
return this.element.not(this.button).text().replace("" + this.options.buttonLabel, "");
}
return this.options.defaultText;
},
_getLang: function() {
- if (this.element.attr("lang")) return this.element.attr("lang");
- if (this.options.lang) return this.options.lang;
+ if (this.element.attr("lang")) {
+ return this.element.attr("lang");
+ }
+ if (this.options.lang) {
+ return this.options.lang;
+ }
},
_getGender: function() {
- if (this.element.attr("gender")) return this.element.attr("gender");
- if (this.options.gender) return this.options.gender;
+ if (this.element.attr("gender")) {
+ return this.element.attr("gender");
+ }
+ if (this.options.gender) {
+ return this.options.gender;
+ }
},
preset: function(lang, gender) {
var presets, res;
- if (lang == null) lang = "en";
- if (gender == null) gender = "male";
+ if (lang == null) {
+ lang = "en";
+ }
+ if (gender == null) {
+ gender = "male";
+ }
presets = {
"de-male": ["LOCALE=de", "VOICE=bits3"],
"de-female": ["LOCALE=de", "VOICE=bits1-hsmm"],
@@ -100,7 +131,9 @@
};
res = presets["" + lang + "-" + gender];
if (!res) {
- console.error("There's no TTS preset defined for " + lang + " and " + gender + ".");
+ if (typeof console !== "undefined" && console !== null) {
+ console.error("There's no TTS preset defined for " + lang + " and " + gender + ".");
+ }
}
return res || presets["de-female"];
},
Please sign in to comment.
Something went wrong with that request. Please try again.