Index: chrome/browser/resources/access_chromevox/audio/background/flash_gooss_engine.js |
=================================================================== |
--- chrome/browser/resources/access_chromevox/audio/background/flash_gooss_engine.js (revision 0) |
+++ chrome/browser/resources/access_chromevox/audio/background/flash_gooss_engine.js (revision 0) |
@@ -0,0 +1,97 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * @fileoverview Text-To-Speech engine powered by GooSS. This engine relies on |
+ * Flash. |
+ * TODO: Remove this engine once the audio tag is fixed and we can cut over |
+ * to plain GooSS. |
+ */ |
+ |
+goog.provide('cvox.ChromeVoxFlashGoossEngine'); |
+ |
+goog.require('cvox.AbstractTts'); |
+ |
+/** |
+ * @constructor |
+ * @extends {cvox.AbstractTts} |
+ */ |
+cvox.ChromeVoxFlashGoossEngine = function() { |
+ //Inherit AbstractTts |
+ cvox.AbstractTts.call(this); |
+ |
+ this.speech = null; |
+ this.speaking = false; |
+ |
+ var theScript = document.createElement('script'); |
+ theScript.type = 'text/javascript'; |
+ theScript.src = |
+ 'http://www.gstatic.com/speech/api/tts/google-network-tts.js'; |
+ document.getElementsByTagName('head')[0].appendChild(theScript); |
+ var context = this; |
+ theScript.onload = function() { |
+ goog.tts = goog.tts || undefined; |
+ context.speech = goog.tts; |
+ context.speech.initialize(); |
+ }; |
+}; |
+goog.inherits(cvox.ChromeVoxFlashGoossEngine, cvox.AbstractTts); |
+ |
+/** |
+ * @return {string} The human-readable name of the speech engine. |
+ */ |
+cvox.ChromeVoxFlashGoossEngine.prototype.getName = function() { |
+ return 'Google Network Speech using Flash'; |
+}; |
+ |
+/** |
+ * Speaks the given string using the specified queueMode and properties. |
+ * @param {string} textString The string of text to be spoken. |
+ * @param {number=} queueMode The queue mode: AbstractTts.QUEUE_MODE_FLUSH |
+ * for flush, AbstractTts.QUEUE_MODE_QUEUE for adding to queue. |
+ * @param {Object=} properties Speech properties to use for this utterance. |
+ */ |
+cvox.ChromeVoxFlashGoossEngine.prototype.speak = function(textString, |
+ queueMode, properties) { |
+ if (!this.speech) { |
+ console.log(this.getName() + ' is not initialized yet.'); |
+ return; |
+ } |
+ cvox.ChromeVoxFlashGoossEngine.superClass_.speak.call(this, textString, |
+ queueMode, properties); |
+ // TODO: Implement speech queue so that queued speech is possible |
+ this.speaking = true; |
+ var queue = (queueMode === cvox.AbstractTts.QUEUE_MODE_QUEUE); |
+ this.speech.speak(textString, |
+ function(event) { |
+ this.isSpeaking = false; |
+ }, queue, cvox.ChromeVoxFlashGoossEngine.DEFAULT_PROPERTIES_JSON); |
+}; |
+ |
+/** |
+ * Returns true if the TTS is currently speaking. |
+ * @return {boolean} True if the TTS is speaking. |
+ */ |
+cvox.ChromeVoxFlashGoossEngine.prototype.isSpeaking = function() { |
+ cvox.ChromeVoxFlashGoossEngine.superClass_.isSpeaking.call(this); |
+ return this.speaking; |
+}; |
+ |
+/** |
+ * Stops speech. |
+ */ |
+cvox.ChromeVoxFlashGoossEngine.prototype.stop = function() { |
+ if (!this.speech) { |
+ return; |
+ } |
+ cvox.ChromeVoxFlashGoossEngine.superClass_.stop.call(this); |
+ this.speaking = false; |
+ this.speech.stopSpeaking(); |
+}; |
+ |
+/** |
+ * The default properties array used for speaking. |
+ * @type {Object} |
+ */ |
+cvox.ChromeVoxFlashGoossEngine.DEFAULT_PROPERTIES_JSON = {'lang': 'en-US'}; |
Property changes on: chrome/browser/resources/access_chromevox/audio/background/flash_gooss_engine.js |
___________________________________________________________________ |
Added: svn:executable |
+ * |
Added: svn:eol-style |
+ LF |