1// Copyright (c) 2012 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 { 7 "namespace": "tts", 8 "description": "Use the <code>chrome.tts</code> API to play synthesized text-to-speech (TTS). See also the related <a href='http://developer.chrome.com/extensions/ttsEngine'>ttsEngine</a> API, which allows an extension to implement a speech engine.", 9 "types": [ 10 { 11 "id": "EventType", 12 "type": "string", 13 "enum": ["start", "end", "word", "sentence", "marker", "interrupted", "cancelled", "error", "pause", "resume"] 14 }, 15 { 16 "id": "VoiceGender", 17 "type": "string", 18 "deprecated": "Gender is deprecated and is ignored.", 19 "enum": ["male", "female"] 20 }, 21 { 22 "id": "TtsOptions", 23 "type": "object", 24 "description": "The speech options for the TTS engine.", 25 "properties": { 26 "enqueue": { 27 "type": "boolean", 28 "optional": true, 29 "description": "If true, enqueues this utterance if TTS is already in progress. If false (the default), interrupts any current speech and flushes the speech queue before speaking this new utterance." 30 }, 31 "voiceName": { 32 "type": "string", 33 "optional": true, 34 "description": "The name of the voice to use for synthesis. If empty, uses any available voice." 35 }, 36 "extensionId": { 37 "type": "string", 38 "optional": true, 39 "description": "The extension ID of the speech engine to use, if known." 40 }, 41 "lang": { 42 "type": "string", 43 "optional": true, 44 "description": "The language to be used for synthesis, in the form <em>language</em>-<em>region</em>. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'." 45 }, 46 "gender": { 47 "$ref": "VoiceGender", 48 "optional": true, 49 "deprecated": "Gender is deprecated and will be ignored.", 50 "description": "Gender of voice for synthesized speech." 51 }, 52 "rate": { 53 "type": "number", 54 "optional": true, 55 "minimum": 0.1, 56 "maximum": 10, 57 "description": "Speaking rate relative to the default rate for this voice. 1.0 is the default rate, normally around 180 to 220 words per minute. 2.0 is twice as fast, and 0.5 is half as fast. Values below 0.1 or above 10.0 are strictly disallowed, but many voices will constrain the minimum and maximum rates further—for example a particular voice may not actually speak faster than 3 times normal even if you specify a value larger than 3.0." 58 }, 59 "pitch": { 60 "type": "number", 61 "optional": true, 62 "minimum": 0, 63 "maximum": 2, 64 "description": "Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to a voice's default pitch." 65 }, 66 "volume": { 67 "type": "number", 68 "optional": true, 69 "minimum": 0, 70 "maximum": 1, 71 "description": "Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0." 72 }, 73 "requiredEventTypes": { 74 "type": "array", 75 "items": {"type": "string"}, 76 "optional": true, 77 "description": "The TTS event types the voice must support." 78 }, 79 "desiredEventTypes": { 80 "type": "array", 81 "items": {"type": "string"}, 82 "optional": true, 83 "description": "The TTS event types that you are interested in listening to. If missing, all event types may be sent." 84 }, 85 "onEvent": { 86 "type": "function", 87 "optional": true, 88 "description": "This function is called with events that occur in the process of speaking the utterance.", 89 "parameters": [ 90 { 91 "name": "event", 92 "$ref": "TtsEvent", 93 "description": "The update event from the text-to-speech engine indicating the status of this utterance." 94 } 95 ] 96 } 97 } 98 }, 99 { 100 "id": "TtsEvent", 101 "type": "object", 102 "description": "An event from the TTS engine to communicate the status of an utterance.", 103 "properties": { 104 "type": { 105 "$ref": "EventType", 106 "description": "The type can be <code>start</code> as soon as speech has started, <code>word</code> when a word boundary is reached, <code>sentence</code> when a sentence boundary is reached, <code>marker</code> when an SSML mark element is reached, <code>end</code> when the end of the utterance is reached, <code>interrupted</code> when the utterance is stopped or interrupted before reaching the end, <code>cancelled</code> when it's removed from the queue before ever being synthesized, or <code>error</code> when any other error occurs. When pausing speech, a <code>pause</code> event is fired if a particular utterance is paused in the middle, and <code>resume</code> if an utterance resumes speech. Note that pause and resume events may not fire if speech is paused in-between utterances." 107 }, 108 "charIndex": { 109 "type": "integer", 110 "optional": true, 111 "description": "The index of the current character in the utterance. For word events, the event fires at the end of one word and before the beginning of the next. The <code>charIndex</code> represents a point in the text at the beginning of the next word to be spoken." 112 }, 113 "errorMessage": { 114 "type": "string", 115 "description": "The error description, if the event type is <code>error</code>.", 116 "optional": true 117 }, 118 "srcId": { 119 "type": "number", 120 "description": "An ID unique to the calling function's context so that events can get routed back to the correct tts.speak call.", 121 "nodoc": true, 122 "optional": true 123 }, 124 "isFinalEvent": { 125 "type": "boolean", 126 "description": "True if this is the final event that will be sent to this handler.", 127 "nodoc": true, 128 "optional": true 129 }, 130 "length": { 131 "type": "integer", 132 "optional": true, 133 "description": "The length of the next part of the utterance. For example, in a <code>word</code> event, this is the length of the word which will be spoken next. It will be set to -1 if not set by the speech engine." 134 } 135 } 136 }, 137 { 138 "id": "TtsVoice", 139 "type": "object", 140 "description": "A description of a voice available for speech synthesis.", 141 "properties": { 142 "voiceName": { 143 "type": "string", 144 "optional": true, 145 "description": "The name of the voice." 146 }, 147 "lang": { 148 "type": "string", 149 "optional": true, 150 "description": "The language that this voice supports, in the form <em>language</em>-<em>region</em>. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'." 151 }, 152 "gender": { 153 "$ref": "VoiceGender", 154 "optional": true, 155 "deprecated": "Gender is deprecated and will be ignored.", 156 "description": "This voice's gender." 157 }, 158 "remote": { 159 "type": "boolean", 160 "optional": true, 161 "description": "If true, the synthesis engine is a remote network resource. It may be higher latency and may incur bandwidth costs." 162 }, 163 "extensionId": { 164 "type": "string", 165 "optional": true, 166 "description": "The ID of the extension providing this voice." 167 }, 168 "eventTypes": { 169 "type": "array", 170 "items": {"$ref": "EventType"}, 171 "optional": true, 172 "description": "All of the callback event types that this voice is capable of sending." 173 } 174 } 175 } 176 ], 177 "functions": [ 178 { 179 "name": "speak", 180 "type": "function", 181 "description": "Speaks text using a text-to-speech engine.", 182 "parameters": [ 183 { 184 "type": "string", 185 "name": "utterance", 186 "description": "The text to speak, either plain text or a complete, well-formed SSML document. Speech engines that do not support SSML will strip away the tags and speak the text. The maximum length of the text is 32,768 characters." 187 }, 188 { 189 "$ref": "TtsOptions", 190 "name": "options", 191 "optional": true, 192 "description": "The speech options." 193 }, 194 { 195 "type": "function", 196 "name": "callback", 197 "optional": true, 198 "description": "Called right away, before speech finishes. Check $(ref:runtime.lastError) to make sure there were no errors. Use options.onEvent to get more detailed feedback.", 199 "parameters": [] 200 } 201 ] 202 }, 203 { 204 "name": "stop", 205 "type": "function", 206 "description": "Stops any current speech and flushes the queue of any pending utterances. In addition, if speech was paused, it will now be un-paused for the next call to speak.", 207 "parameters": [] 208 }, 209 { 210 "name": "pause", 211 "type": "function", 212 "description": "Pauses speech synthesis, potentially in the middle of an utterance. A call to resume or stop will un-pause speech.", 213 "parameters": [] 214 }, 215 { 216 "name": "resume", 217 "type": "function", 218 "description": "If speech was paused, resumes speaking where it left off.", 219 "parameters": [] 220 }, 221 { 222 "name": "isSpeaking", 223 "type": "function", 224 "description": "Checks whether the engine is currently speaking. On Mac OS X, the result is true whenever the system speech engine is speaking, even if the speech wasn't initiated by Chrome.", 225 "parameters": [ 226 { 227 "type": "function", 228 "name": "callback", 229 "optional": true, 230 "parameters": [ 231 { 232 "name": "speaking", 233 "type": "boolean", 234 "description": "True if speaking, false otherwise." 235 } 236 ] 237 } 238 ] 239 }, 240 { 241 "name": "getVoices", 242 "type": "function", 243 "description": "Gets an array of all available voices.", 244 "parameters": [ 245 { 246 "type": "function", 247 "name": "callback", 248 "optional": true, 249 "parameters": [ 250 { 251 "type": "array", 252 "name": "voices", 253 "items": { "$ref": "TtsVoice" }, 254 "description": "Array of $(ref:tts.TtsVoice) objects representing the available voices for speech synthesis." 255 } 256 ] 257 } 258 ] 259 } 260 ], 261 "events": [ 262 { 263 "name": "onEvent", 264 "type": "function", 265 "nodoc": true, 266 "parameters": [ 267 { 268 "name": "event", 269 "$ref": "TtsEvent", 270 "description": "The event from the text-to-speech engine indicating the status of this utterance." 271 } 272 ], 273 "description": "Used to pass events back to the function calling speak()." 274 } 275 ] 276 } 277] 278