Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/browser/resources/access_chromevox/audio/background/flash_gooss_engine.js

Issue 6254007: Adding ChromeVox as a component extensions (enabled only for ChromeOS, for no... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Text-To-Speech engine powered by GooSS. This engine relies on
7 * Flash.
8 * TODO: Remove this engine once the audio tag is fixed and we can cut over
9 * to plain GooSS.
10 */
11
12 goog.provide('cvox.ChromeVoxFlashGoossEngine');
13
14 goog.require('cvox.AbstractTts');
15
16 /**
17 * @constructor
18 * @extends {cvox.AbstractTts}
19 */
20 cvox.ChromeVoxFlashGoossEngine = function() {
21 //Inherit AbstractTts
22 cvox.AbstractTts.call(this);
23
24 this.speech = null;
25 this.speaking = false;
26
27 var theScript = document.createElement('script');
28 theScript.type = 'text/javascript';
29 theScript.src =
30 'http://www.gstatic.com/speech/api/tts/google-network-tts.js';
31 document.getElementsByTagName('head')[0].appendChild(theScript);
32 var context = this;
33 theScript.onload = function() {
34 goog.tts = goog.tts || undefined;
35 context.speech = goog.tts;
36 context.speech.initialize();
37 };
38 };
39 goog.inherits(cvox.ChromeVoxFlashGoossEngine, cvox.AbstractTts);
40
41 /**
42 * @return {string} The human-readable name of the speech engine.
43 */
44 cvox.ChromeVoxFlashGoossEngine.prototype.getName = function() {
45 return 'Google Network Speech using Flash';
46 };
47
48 /**
49 * Speaks the given string using the specified queueMode and properties.
50 * @param {string} textString The string of text to be spoken.
51 * @param {number=} queueMode The queue mode: AbstractTts.QUEUE_MODE_FLUSH
52 * for flush, AbstractTts.QUEUE_MODE_QUEUE for adding to queue.
53 * @param {Object=} properties Speech properties to use for this utterance.
54 */
55 cvox.ChromeVoxFlashGoossEngine.prototype.speak = function(textString,
56 queueMode, properties) {
57 if (!this.speech) {
58 console.log(this.getName() + ' is not initialized yet.');
59 return;
60 }
61 cvox.ChromeVoxFlashGoossEngine.superClass_.speak.call(this, textString,
62 queueMode, properties);
63 // TODO: Implement speech queue so that queued speech is possible
64 this.speaking = true;
65 var queue = (queueMode === cvox.AbstractTts.QUEUE_MODE_QUEUE);
66 this.speech.speak(textString,
67 function(event) {
68 this.isSpeaking = false;
69 }, queue, cvox.ChromeVoxFlashGoossEngine.DEFAULT_PROPERTIES_JSON);
70 };
71
72 /**
73 * Returns true if the TTS is currently speaking.
74 * @return {boolean} True if the TTS is speaking.
75 */
76 cvox.ChromeVoxFlashGoossEngine.prototype.isSpeaking = function() {
77 cvox.ChromeVoxFlashGoossEngine.superClass_.isSpeaking.call(this);
78 return this.speaking;
79 };
80
81 /**
82 * Stops speech.
83 */
84 cvox.ChromeVoxFlashGoossEngine.prototype.stop = function() {
85 if (!this.speech) {
86 return;
87 }
88 cvox.ChromeVoxFlashGoossEngine.superClass_.stop.call(this);
89 this.speaking = false;
90 this.speech.stopSpeaking();
91 };
92
93 /**
94 * The default properties array used for speaking.
95 * @type {Object}
96 */
97 cvox.ChromeVoxFlashGoossEngine.DEFAULT_PROPERTIES_JSON = {'lang': 'en-US'};
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698