console_tts.js revision cedac228d2dd51db4b79ea1e72c7f249408ee061
1// Copyright 2014 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 A TTS engine that writes to window.console.
7 */
8
9goog.provide('cvox.ConsoleTts');
10
11goog.require('cvox.AbstractTts');
12goog.require('cvox.TtsInterface');
13
14/**
15 * @constructor
16 * @implements {cvox.TtsInterface}
17 */
18cvox.ConsoleTts = function() {
19  /**
20   * True if the console TTS is enabled by the user.
21   * @type {boolean}
22   * @private
23   */
24  this.enabled_ = false;
25};
26goog.addSingletonGetter(cvox.ConsoleTts);
27
28
29/** @override */
30cvox.ConsoleTts.prototype.speak = function(textString, queueMode, properties) {
31  if (this.enabled_ && window['console']) {
32    var logStr = 'Speak';
33    if (queueMode == cvox.AbstractTts.QUEUE_MODE_FLUSH) {
34      logStr += ' (I)';
35    } else {
36      logStr += ' (Q)';
37    }
38    logStr += ' "' + textString + '"';
39    window['console']['log'](logStr);
40
41    if (properties && properties['startCallback'] != undefined) {
42      window.console.log('  using startCallback');
43    }
44
45    if (properties && properties['endCallback'] != undefined) {
46      window.console.log('  using endCallback');
47    }
48  }
49  return this;
50};
51
52/** @override */
53cvox.ConsoleTts.prototype.isSpeaking = function() { return false; };
54
55/** @override */
56cvox.ConsoleTts.prototype.stop = function() {
57  if (this.enabled_) {
58    window['console']['log']('Stop');
59  }
60};
61
62/** @override */
63cvox.ConsoleTts.prototype.addCapturingEventListener = function(listener) { };
64
65/** @override */
66cvox.ConsoleTts.prototype.increaseOrDecreaseProperty = function() { };
67
68/**
69 * Sets the enabled bit.
70 * @param {boolean} enabled The new enabled bit.
71 */
72cvox.ConsoleTts.prototype.setEnabled = function(enabled) {
73  this.enabled_ = enabled;
74};
75
76/** @override */
77cvox.ConsoleTts.prototype.getDefaultProperty = function(property) { };
78