OLD | NEW |
(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 Sends Text-To-Speech commands to a separate Chrome extension. |
| 7 */ |
| 8 |
| 9 // Substituted by package.py |
| 10 var ttsExtensionId = 'jhfhnnjfmmflacfniolmefnflomjcbdf'; |
| 11 |
| 12 goog.provide('cvox.ChromeVoxExtensionTtsEngine'); |
| 13 |
| 14 goog.require('cvox.AbstractTts'); |
| 15 |
| 16 /** |
| 17 * @constructor |
| 18 * @extends {cvox.AbstractTts} |
| 19 */ |
| 20 cvox.ChromeVoxExtensionTtsEngine = function() { |
| 21 //Inherit AbstractTts |
| 22 cvox.AbstractTts.call(this); |
| 23 |
| 24 this.ttsExtensionPort = chrome.extension.connect(ttsExtensionId); |
| 25 }; |
| 26 goog.inherits(cvox.ChromeVoxExtensionTtsEngine, cvox.AbstractTts); |
| 27 |
| 28 /** |
| 29 * @return {string} The human-readable name of the speech engine. |
| 30 */ |
| 31 cvox.ChromeVoxExtensionTtsEngine.prototype.getName = function() { |
| 32 return 'Native Client Pico Speech'; |
| 33 }; |
| 34 |
| 35 /** |
| 36 * Speaks the given string using the specified queueMode and properties. |
| 37 * @param {string} textString The string of text to be spoken. |
| 38 * @param {number=} queueMode The queue mode: AbstractTts.QUEUE_MODE_FLUSH |
| 39 * for flush, AbstractTts.QUEUE_MODE_QUEUE for adding to queue. |
| 40 * @param {Object=} properties Speech properties to use for this utterance. |
| 41 */ |
| 42 cvox.ChromeVoxExtensionTtsEngine.prototype.speak = function( |
| 43 textString, queueMode, properties) { |
| 44 cvox.ChromeVoxExtensionTtsEngine.superClass_.speak.call(this, textString, |
| 45 queueMode, properties); |
| 46 // TODO: the TTS extension should handle queueMode directly. |
| 47 if (queueMode == cvox.AbstractTts.QUEUE_MODE_FLUSH) { |
| 48 this.stop(); |
| 49 } |
| 50 |
| 51 this.ttsExtensionPort.postMessage( |
| 52 {'action': 'speak', |
| 53 'text': textString, |
| 54 'queueMode': queueMode, |
| 55 'properties': properties}); |
| 56 }; |
| 57 |
| 58 /** |
| 59 * Returns true if the TTS is currently speaking. |
| 60 * @return {boolean} True if the TTS is speaking. |
| 61 */ |
| 62 cvox.ChromeVoxExtensionTtsEngine.prototype.isSpeaking = function() { |
| 63 cvox.ChromeVoxExtensionTtsEngine.superClass_.isSpeaking.call(this); |
| 64 // TODO: Fix this. |
| 65 return false; |
| 66 }; |
| 67 |
| 68 /** |
| 69 * Stops speech. |
| 70 */ |
| 71 cvox.ChromeVoxExtensionTtsEngine.prototype.stop = function() { |
| 72 cvox.ChromeVoxExtensionTtsEngine.superClass_.stop.call(this); |
| 73 this.ttsExtensionPort.postMessage( |
| 74 {'action': 'stop'}); |
| 75 }; |
OLD | NEW |