Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / chromeos / chromevox / host / interface / tts_interface.js
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 Defines a Tts interface.
7  *
8  * All TTS engines in ChromeVox conform to the this interface.
9  *
10  */
11
12 goog.provide('cvox.QueueMode');
13 goog.provide('cvox.TtsCapturingEventListener');
14 goog.provide('cvox.TtsCategory');
15 goog.provide('cvox.TtsInterface');
16
17 /**
18  * Categories for a speech utterance. This can be used with the
19  * CATEGORY_FLUSH queue mode, which flushes all utterances from a given
20  * category but not other utterances.
21  *
22  * NAV: speech related to explicit navigation, or focus changing.
23  * LIVE: speech coming from changes to live regions.
24  *
25  * @enum {string}
26  */
27 cvox.TtsCategory = {
28   LIVE: 'live',
29   NAV: 'nav'
30 };
31
32 /**
33  * Queue modes for calls to {@code cvox.TtsInterface.speak}.
34  * @enum
35  */
36 cvox.QueueMode = {
37   /** Stop speech, clear everything, then speak this utterance. */
38   FLUSH: 0,
39
40   /** Append this utterance to the end of the queue. */
41   QUEUE: 1,
42
43   /**
44    * Clear any utterances of the same category (as set by
45    * properties['category']) from the queue, then enqueue this utterance.
46    */
47   CATEGORY_FLUSH: 2
48 };
49
50 /**
51  * @interface
52  * An interface for clients who want to get notified when an utterance
53  * starts or ends from any source.
54  */
55 cvox.TtsCapturingEventListener = function() { };
56
57 /**
58  * Called when any utterance starts.
59  */
60 cvox.TtsCapturingEventListener.prototype.onTtsStart = function() { };
61
62 /**
63  * Called when any utterance ends.
64  */
65 cvox.TtsCapturingEventListener.prototype.onTtsEnd = function() { };
66
67
68 /**
69  * @interface
70  */
71 cvox.TtsInterface = function() { };
72
73 /**
74  * Speaks the given string using the specified queueMode and properties.
75  * @param {string} textString The string of text to be spoken.
76  * @param {cvox.QueueMode} queueMode The queue mode to use for speaking.
77  * @param {Object=} properties Speech properties to use for this utterance.
78  * @return {cvox.TtsInterface} A tts object useful for chaining speak calls.
79  */
80 cvox.TtsInterface.prototype.speak =
81     function(textString, queueMode, properties) { };
82
83
84 /**
85  * Returns true if the TTS is currently speaking.
86  * @return {boolean} True if the TTS is speaking.
87  */
88 cvox.TtsInterface.prototype.isSpeaking = function() { };
89
90
91 /**
92  * Stops speech.
93  */
94 cvox.TtsInterface.prototype.stop = function() { };
95
96 /**
97  * Adds a listener to get called whenever any utterance starts or ends.
98  * @param {cvox.TtsCapturingEventListener} listener Listener to get called.
99  */
100 cvox.TtsInterface.prototype.addCapturingEventListener = function(listener) { };
101
102 /**
103  * Increases a TTS speech property.
104  * @param {string} propertyName The name of the property to change.
105  * @param {boolean} increase If true, increases the property value by one
106  *     step size, otherwise decreases.
107  */
108 cvox.TtsInterface.prototype.increaseOrDecreaseProperty =
109     function(propertyName, increase) { };
110
111
112 /**
113  * Returns the default properties of the first tts that has default properties.
114  * @param {string} property Name of property.
115  * @return {?number} The default value.
116  */
117 cvox.TtsInterface.prototype.getDefaultProperty = function(property) { };