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 Text-To-Speech engine that is using the Emacspeak |
| 7 * local speech server. |
| 8 */ |
| 9 |
| 10 goog.provide('cvox.ChromeVoxEmacspeakTtsServerEngine'); |
| 11 |
| 12 goog.require('cvox.AbstractTts'); |
| 13 |
| 14 /** |
| 15 * @constructor |
| 16 * @extends {cvox.AbstractTts} |
| 17 */ |
| 18 cvox.ChromeVoxEmacspeakTtsServerEngine = function() { |
| 19 //Inherit AbstractTts |
| 20 cvox.AbstractTts.call(this); |
| 21 }; |
| 22 goog.inherits(cvox.ChromeVoxEmacspeakTtsServerEngine, cvox.AbstractTts); |
| 23 |
| 24 /** |
| 25 * @return {string} The human-readable name of the speech engine. |
| 26 */ |
| 27 cvox.ChromeVoxEmacspeakTtsServerEngine.prototype.getName = function() { |
| 28 return 'Local Speech'; |
| 29 }; |
| 30 |
| 31 /** |
| 32 * Speaks the given string using the specified queueMode and properties. |
| 33 * @param {string} textString The string of text to be spoken. |
| 34 * @param {number=} queueMode The queue mode: AbstractTts.QUEUE_MODE_FLUSH |
| 35 * for flush, AbstractTts.QUEUE_MODE_QUEUE for adding to queue. |
| 36 * @param {Object=} properties Speech properties to use for this utterance. |
| 37 */ |
| 38 cvox.ChromeVoxEmacspeakTtsServerEngine.prototype.speak = function( |
| 39 textString, queueMode, properties) { |
| 40 cvox.ChromeVoxEmacspeakTtsServerEngine.superClass_.speak.call(this, |
| 41 textString, queueMode, properties); |
| 42 if (queueMode == cvox.AbstractTts.QUEUE_MODE_FLUSH) { |
| 43 this.stop(); |
| 44 } |
| 45 var emacspeakConnection = new XMLHttpRequest(); |
| 46 emacspeakConnection.overrideMimeType('text/xml'); |
| 47 emacspeakConnection.open('POST', 'http://127.0.0.1:8000', true); |
| 48 emacspeakConnection.setRequestHeader('Content-Type', |
| 49 'application/x-www-form-urlencoded'); |
| 50 emacspeakConnection.send('speak: ' + textString); |
| 51 }; |
| 52 |
| 53 /** |
| 54 * @return {boolean} True if the TTS is speaking. |
| 55 */ |
| 56 cvox.ChromeVoxEmacspeakTtsServerEngine.prototype.isSpeaking = function() { |
| 57 cvox.ChromeVoxEmacspeakTtsServerEngine.superClass_.isSpeaking.call(this); |
| 58 return false; |
| 59 }; |
| 60 |
| 61 /** |
| 62 * Stops speech. |
| 63 */ |
| 64 cvox.ChromeVoxEmacspeakTtsServerEngine.prototype.stop = function() { |
| 65 cvox.ChromeVoxEmacspeakTtsServerEngine.superClass_.stop.call(this); |
| 66 var emacspeakConnection = new XMLHttpRequest(); |
| 67 emacspeakConnection.overrideMimeType('text/xml'); |
| 68 emacspeakConnection.open('POST', 'http://127.0.0.1:8000', true); |
| 69 emacspeakConnection.setRequestHeader('Content-Type', |
| 70 'application/x-www-form-urlencoded'); |
| 71 emacspeakConnection.send('stop'); |
| 72 }; |
OLD | NEW |