Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/common/extensions/docs/tts.html

Issue 10642015: Basic setup for generating app docs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc. Note:
2 1) The <head> information in this page is significant, should be uniform
3 across api docs and should be edited only with knowledge of the
4 templating mechanism.
5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a
6 browser, it will be re-generated from the template, json schema and
7 authored overview content.
8 4) The <body>.innerHTML is also generated by an offline step so that this
9 page may easily be indexed by search engines.
10 --><html xmlns="http://www.w3.org/1999/xhtml"><head>
11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
12 <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css">
13 <link href="css/print.css" rel="stylesheet" type="text/css" media="print">
14 <script type="text/javascript" src="../../../third_party/jstemplate/jstempla te_compiled.js">
15 </script>
16 <script type="text/javascript" src="../../../../third_party/json_minify/mini fy-sans-regexp.js">
17 </script>
18 <script type="text/javascript" src="js/api_page_generator.js"></script>
19 <script type="text/javascript" src="js/bootstrap.js"></script>
20 <script type="text/javascript" src="js/sidebar.js"></script>
21 <meta name="description" content="Documentation for the chrome.tts module, whi ch is part of the Google Chrome extension APIs."><title>chrome.tts - Google Chr ome Extensions - Google Code</title></head>
22 <body> <div id="devModeWarning" class="displayModeWarning">
23 You are viewing extension docs in chrome via the 'file:' scheme: are you exp ecting to see local changes when you refresh? You'll need run chrome with --allo w-file-access-from-files.
24 </div>
25 <div id="branchWarning" class="displayModeWarning">
26 <span>WARNING: This is the <span id="branchName">BETA</span> documentation.
27 It may not work with the stable release of Chrome.</span>
28 <select id="branchChooser">
29 <option>Choose a different version...
30 </option><option value="">Stable
31 </option><option value="beta">Beta
32 </option><option value="dev">Dev
33 </option><option value="trunk">Trunk
34 </option></select>
35 </div>
36 <div id="unofficialWarning" class="displayModeWarning">
37 <span>WARNING: This is unofficial documentation. It may not work with the
38 current release of Chrome.</span>
39 <button id="goToOfficialDocs">Go to the official docs</button>
40 </div>
41 <div id="gc-container" class="labs">
42 <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION -->
43 <!-- In particular, sub-templates that recurse, must be used by allowing
44 jstemplate to make a copy of the template in this section which
45 are not operated on by way of the jsskip="true" -->
46 <!-- /SUBTEMPLATES -->
47 <a id="top"></a>
48 <div id="skipto">
49 <a href="#gc-pagecontent">Skip to page content</a>
50 <a href="#gc-toc">Skip to main navigation</a>
51 </div>
52 <!-- API HEADER -->
53 <table id="header" width="100%" cellspacing="0" border="0">
54 <tbody><tr>
55 <td valign="middle"><a href="http://code.google.com/"><img src="images/c ode_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border: 0; margin:0;"></a></td>
56 <td valign="middle" width="100%" style="padding-left:0.6em;">
57 <form action="http://www.google.com/cse" id="cse" style="margin-top:0. 5em">
58 <div id="gsc-search-box">
59 <input type="hidden" name="cx" value="002967670403910741006:61_cvz fqtno">
60 <input type="hidden" name="ie" value="UTF-8">
61 <input type="text" name="q" value="" size="55">
62 <input class="gsc-search-button" type="submit" name="sa" value="Se arch">
63 <br>
64 <span class="greytext">e.g. "page action" or "tabs"</span>
65 </div>
66 </form>
67 <script type="text/javascript" src="https://www.google.com/jsapi"></sc ript>
68 <script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script>
69 <script type="text/javascript" src="https://www.google.com/coop/cse/t1 3n?form=cse&amp;t13n_langs=en"></script>
70 <script type="text/javascript" src="https://www.google.com/coop/cse/br and?form=cse&amp;lang=en"></script>
71 </td>
72 </tr>
73 </tbody></table>
74 <div id="codesiteContent" class="">
75 <a id="gc-topnav-anchor"></a>
76 <div id="gc-topnav">
77 <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Lab s</a>)</h1>
78 <ul id="home" class="gc-topnav-tabs">
79 <li id="home_link">
80 <a href="index.html" title="Google Chrome Extensions home page">Home </a>
81 </li>
82 <li id="docs_link">
83 <a href="docs.html" title="Official Google Chrome Extensions documen tation">Docs</a>
84 </li>
85 <li id="faq_link">
86 <a href="faq.html" title="Answers to frequently asked questions abou t Google Chrome Extensions">FAQ</a>
87 </li>
88 <li id="samples_link">
89 <a href="samples.html" title="Sample extensions (with source code)"> Samples</a>
90 </li>
91 <li id="group_link">
92 <a href="http://groups.google.com/a/chromium.org/group/chromium-exte nsions" title="Google Chrome Extensions developer forum">Group</a>
93 </li>
94 <li id="so_link">
95 <a href="http://stackoverflow.com/questions/tagged/google-chrome-ext ension" title="[google-chrome-extension] tag on Stack Overflow">Questions?</a>
96 </li>
97 </ul>
98 </div> <!-- end gc-topnav -->
99 <div class="g-section g-tpl-170">
100 <!-- SIDENAV -->
101 <div class="g-unit g-first" id="gc-toc">
102 <ul>
103 <li><a href="getstarted.html">Getting Started</a></li>
104 <li><a href="overview.html">Overview</a></li>
105 <li><a href="whats_new.html">What's New?</a></li>
106 <li><h2><a href="devguide.html">Developer's Guide</a></h2>
107 <ul>
108 <li>Browser UI
109 <ul>
110 <li><a href="browserAction.html">Browser Actions</a></li>
111 <li><a href="contextMenus.html">Context Menus</a></li>
112 <li><a href="notifications.html">Desktop Notifications</a></li >
113 <li><a href="omnibox.html">Omnibox</a></li>
114 <li><a href="options.html">Options Pages</a></li>
115 <li><a href="override.html">Override Pages</a></li>
116 <li><a href="pageAction.html">Page Actions</a></li>
117 </ul>
118 </li>
119 <li>Browser Interaction
120 <ul>
121 <li><a href="bookmarks.html">Bookmarks</a></li>
122 <li><a href="cookies.html">Cookies</a></li>
123 <li><a href="devtools.html">Developer Tools</a></li>
124 <li><a href="events.html">Events</a></li>
125 <li><a href="history.html">History</a></li>
126 <li><a href="management.html">Management</a></li>
127 <li><a href="tabs.html">Tabs</a></li>
128 <li><a href="windows.html">Windows</a></li>
129 </ul>
130 </li>
131 <li>Implementation
132 <ul>
133 <li><a href="a11y.html">Accessibility</a></li>
134 <li><a href="background_pages.html">Background Pages</a></li>
135 <li><a href="content_scripts.html">Content Scripts</a></li>
136 <li><a href="xhr.html">Cross-Origin XHR</a></li>
137 <li><a href="i18n.html">Internationalization</a></li>
138 <li><a href="messaging.html">Message Passing</a></li>
139 <li><a href="permissions.html">Optional Permissions</a></li>
140 <li><a href="npapi.html">NPAPI Plugins</a></li>
141 </ul>
142 </li>
143 <li>Finishing
144 <ul>
145 <li><a href="hosting.html">Hosting</a></li>
146 <li><a href="external_extensions.html">Other Deployment Option s</a></li>
147 </ul>
148 </li>
149 </ul>
150 </li>
151 <li><h2><a href="apps.html">Packaged Apps</a></h2></li>
152 <li><h2><a href="tutorials.html">Tutorials</a></h2>
153 <ul>
154 <li><a href="tut_debugging.html">Debugging</a></li>
155 <li><a href="tut_analytics.html">Google Analytics</a></li>
156 <li><a href="tut_oauth.html">OAuth</a></li>
157 </ul>
158 </li>
159 <li><h2>Reference</h2>
160 <ul>
161 <li>Formats
162 <ul>
163 <li><a href="manifest.html">Manifest Files</a></li>
164 <li><a href="match_patterns.html">Match Patterns</a></li>
165 </ul>
166 </li>
167 <li><a href="permission_warnings.html">Permission Warnings</a></li >
168 <li><a href="api_index.html">chrome.* APIs</a></li>
169 <li><a href="api_other.html">Other APIs</a></li>
170 </ul>
171 </li>
172 <li><h2><a href="samples.html">Samples</a></h2></li>
173 <div class="line"> </div>
174 <li><h2>More</h2>
175 <ul>
176 <li><a href="http://code.google.com/chrome/webstore/docs/index.htm l">Chrome Web Store</a></li>
177 <li><a href="http://code.google.com/chrome/apps/docs/developers_gu ide.html">Hosted Apps</a></li>
178 <li><a href="themes.html">Themes</a></li>
179 </ul>
180 </li>
181 </ul>
182 </div>
183 <script>
184 initToggles();
185 </script>
186 <div class="g-unit" id="gc-pagecontent">
187 <div id="pageTitle">
188 <h1 class="page_title">chrome.tts</h1>
189 </div>
190 <!-- TABLE OF CONTENTS -->
191 <div id="toc">
192 <h2>Contents</h2>
193 <ol>
194 <li>
195 <a href="#overview">Overview</a>
196 <ol>
197 </ol>
198 </li><li>
199 <a href="#generating_speech">Generating speech</a>
200 <ol>
201 </ol>
202 </li><li>
203 <a href="#events">Listening to events</a>
204 <ol>
205 </ol>
206 </li><li>
207 <a href="#ssml">SSML markup</a>
208 <ol>
209 </ol>
210 </li><li>
211 <a href="#choosing_voice">Choosing a voice</a>
212 <ol>
213 </ol>
214 </li>
215 <li>
216 <a href="#apiReference">API reference: chrome.tts</a>
217 <ol>
218 <li>
219 <a href="#global-methods">Methods</a>
220 <ol>
221 <li>
222 <a href="#method-getVoices">getVoices</a>
223 </li><li>
224 <a href="#method-isSpeaking">isSpeaking</a>
225 </li><li>
226 <a href="#method-speak">speak</a>
227 </li><li>
228 <a href="#method-stop">stop</a>
229 </li>
230 </ol>
231 </li>
232 <li>
233 <a href="#types">Types</a>
234 <ol>
235 <li>
236 <a href="#type-TtsEvent">TtsEvent</a>
237 <ol>
238 </ol>
239 </li><li>
240 <a href="#type-TtsVoice">TtsVoice</a>
241 <ol>
242 </ol>
243 </li>
244 </ol>
245 </li>
246 </ol>
247 </li>
248 </ol>
249 </div>
250 <!-- /TABLE OF CONTENTS -->
251 <!-- Standard content lead-in for experimental API pages -->
252 <!-- STATIC CONTENT PLACEHOLDER -->
253 <div id="static"><p id="classSummary">
254 Use the <code>chrome.tts</code> module to play synthesized
255 text-to-speech (TTS) from your extension or packaged app.
256 See also the related
257 <a href="ttsEngine.html">ttsEngine</a>
258 module, which allows an extension to implement a speech engine.
259 </p>
260 <h2 id="overview">Overview</h2>
261 <p>You must declare the "tts" permission
262 in your extension's manifest to use this API.
263 </p>
264 <p>Chrome provides native support for speech on Windows (using SAPI
265 5), Mac OS X, and Chrome OS, using speech synthesis capabilities
266 provided by the operating system. On all platforms, the user can
267 install extensions that register themselves as alternative speech
268 engines.</p>
269 <h2 id="generating_speech">Generating speech</h2>
270 <p>Call <code>speak()</code> from your extension or
271 packaged app to speak. For example:</p>
272 <pre>chrome.tts.speak('Hello, world.');</pre>
273 <p>To stop speaking immediately, just call <code>stop()</code>:
274 </p><pre>chrome.tts.stop();</pre>
275 <p>You can provide options that control various properties of the speech,
276 such as its rate, pitch, and more. For example:</p>
277 <pre>chrome.tts.speak('Hello, world.', {'rate': 2.0});</pre>
278 <p>It's also a good idea to specify the language so that a synthesizer
279 supporting that language (and regional dialect, if applicable) is chosen.</p>
280 <pre>chrome.tts.speak(
281 'Hello, world.', {'lang': 'en-US', 'rate': 2.0});</pre>
282 <p>By default, each call to <code>speak()</code> interrupts any
283 ongoing speech and speaks immediately. To determine if a call would be
284 interrupting anything, you can call <code>isSpeaking()</code>. In
285 addition, you can use the <code>enqueue</code> option to cause this
286 utterance to be added to a queue of utterances that will be spoken
287 when the current utterance has finished.</p>
288 <pre>chrome.tts.speak(
289 'Speak this first.');
290 chrome.tts.speak(
291 'Speak this next, when the first sentence is done.', {'enqueue': true});
292 </pre>
293 <p>A complete description of all options can be found in the
294 <a href="#method-speak">speak() method documentation</a> below.
295 Not all speech engines will support all options.</p>
296 <p>To catch errors and make sure you're calling <code>speak()</code>
297 correctly, pass a callback function that takes no arguments. Inside
298 the callback, check
299 <a href="extension.html#property-lastError">chrome.extension.lastError</a>
300 to see if there were any errors.</p>
301 <pre>chrome.tts.speak(
302 utterance,
303 options,
304 function() {
305 if (chrome.extension.lastError) {
306 console.log('Error: ' + chrome.extension.lastError.message);
307 }
308 });</pre>
309 <p>The callback returns right away, before the engine has started
310 generating speech. The purpose of the callback is to alert you to
311 syntax errors in your use of the TTS API, not to catch all possible
312 errors that might occur in the process of synthesizing and outputting
313 speech. To catch these errors too, you need to use an event listener,
314 described below.</p>
315 <h2 id="events">Listening to events</h2>
316 <p>To get more real-time information about the status of synthesized speech,
317 pass an event listener in the options to <code>speak()</code>, like this:</p>
318 <pre>chrome.tts.speak(
319 utterance,
320 {
321 onEvent: function(event) {
322 console.log('Event ' + event.type ' at position ' + event.charIndex);
323 if (event.type == 'error') {
324 console.log('Error: ' + event.errorMessage);
325 }
326 }
327 },
328 callback);</pre>
329 <p>Each event includes an event type, the character index of the current
330 speech relative to the utterance, and for error events, an optional
331 error message. The event types are:</p>
332 <ul>
333 <li><code>'start'</code>: The engine has started speaking the utterance.
334 </li><li><code>'word'</code>: A word boundary was reached. Use
335 <code>event.charIndex</code> to determine the current speech
336 position.
337 </li><li><code>'sentence'</code>: A sentence boundary was reached. Use
338 <code>event.charIndex</code> to determine the current speech
339 position.
340 </li><li><code>'marker'</code>: An SSML marker was reached. Use
341 <code>event.charIndex</code> to determine the current speech
342 position.
343 </li><li><code>'end'</code>: The engine has finished speaking the utterance.
344 </li><li><code>'interrupted'</code>: This utterance was interrupted by another
345 call to <code>speak()</code> or <code>stop()</code> and did not
346 finish.
347 </li><li><code>'cancelled'</code>: This utterance was queued, but then
348 cancelled by another call to <code>speak()</code> or
349 <code>stop()</code> and never began to speak at all.
350 </li><li><code>'error'</code>: An engine-specific error occurred and
351 this utterance cannot be spoken.
352 Check <code>event.errorMessage</code> for details.
353 </li></ul>
354 <p>Four of the event types—<code>'end'</code>, <code>'interrupted'</code>,
355 <code>'cancelled'</code>, and <code>'error'</code>—are <i>final</i>.
356 After one of those events is received, this utterance will no longer
357 speak and no new events from this utterance will be received.</p>
358 <p>Some voices may not support all event types, and some voices may not
359 send any events at all. If you do not want to use a voice unless it sends
360 certain events, pass the events you require in the
361 <code>requiredEventTypes</code> member of the options object, or use
362 <code>getVoices()</code> to choose a voice that meets your requirements.
363 Both are documented below.</p>
364 <h2 id="ssml">SSML markup</h2>
365 <p>Utterances used in this API may include markup using the
366 <a href="http://www.w3.org/TR/speech-synthesis">Speech Synthesis Markup
367 Language (SSML)</a>. If you use SSML, the first argument to
368 <code>speak()</code> should be a complete SSML document with an XML
369 header and a top-level <code>&lt;speak&gt;</code> tag, not a document
370 fragment.</p>
371 <p>For example:</p>
372 <pre>chrome.tts.speak(
373 '&lt;?xml version="1.0"?&gt;' +
374 '&lt;speak&gt;' +
375 ' The &lt;emphasis&gt;second&lt;/emphasis&gt; ' +
376 ' word of this sentence was emphasized.' +
377 '&lt;/speak&gt;');</pre>
378 <p>Not all speech engines will support all SSML tags, and some may not support
379 SSML at all, but all engines are required to ignore any SSML they don't
380 support and to still speak the underlying text.</p>
381 <h2 id="choosing_voice">Choosing a voice</h2>
382 <p>By default, Chrome chooses the most appropriate voice for each
383 utterance you want to speak, based on the language and gender. On most
384 Windows, Mac OS X, and Chrome OS systems, speech synthesis provided by
385 the operating system should be able to speak any text in at least one
386 language. Some users may have a variety of voices available, though,
387 from their operating system and from speech engines implemented by other
388 Chrome extensions. In those cases, you can implement custom code to choose
389 the appropriate voice, or to present the user with a list of choices.</p>
390 <p>To get a list of all voices, call <code>getVoices()</code> and pass it
391 a function that receives an array of <code>TtsVoice</code> objects as its
392 argument:</p>
393 <pre>chrome.tts.getVoices(
394 function(voices) {
395 for (var i = 0; i &lt; voices.length; i++) {
396 console.log('Voice ' + i + ':');
397 console.log(' name: ' + voices[i].voiceName);
398 console.log(' lang: ' + voices[i].lang);
399 console.log(' gender: ' + voices[i].gender);
400 console.log(' extension id: ' + voices[i].extensionId);
401 console.log(' event types: ' + voices[i].eventTypes);
402 }
403 });</pre>
404 </div>
405 <!-- API PAGE -->
406 <div class="apiPage">
407 <a name="apiReference"></a>
408 <h2>API reference: chrome.tts</h2>
409 <!-- PROPERTIES -->
410 <!-- /apiGroup -->
411 <!-- METHODS -->
412 <div id="methodsTemplate" class="apiGroup">
413 <a name="global-methods"></a>
414 <h3>Methods</h3>
415 <!-- iterates over all functions -->
416 <div class="apiItem">
417 <a name="method-getVoices"></a> <!-- method-anchor -->
418 <h4>getVoices</h4>
419 <div class="summary">
420 <!-- Note: intentionally longer 80 columns -->
421 <span>chrome.tts.getVoices</span>(<span class="optional"><span >function</span>
422 <var><span>callback</span></var></span>)</div>
423 <div class="description">
424 <p>Gets an array of all available voices.</p>
425 <!-- PARAMETERS -->
426 <h4>Parameters</h4>
427 <dl>
428 <div>
429 <div>
430 <dt>
431 <var>callback</var>
432 <em>
433 <!-- TYPE -->
434 <div style="display:inline">
435 (
436 <span class="optional">optional</span>
437 <span id="typeTemplate">
438 <span>
439 <span>function</span>
440 </span>
441 </span>
442 )
443 </div>
444 </em>
445 </dt>
446 <dd class="todo">
447 Undocumented.
448 </dd>
449 <!-- OBJECT PROPERTIES -->
450 <!-- OBJECT METHODS -->
451 <!-- OBJECT EVENT FIELDS -->
452 <!-- FUNCTION PARAMETERS -->
453 </div>
454 </div>
455 </dl>
456 <!-- RETURNS -->
457 <dl>
458 </dl>
459 <!-- CALLBACK -->
460 <div>
461 <div>
462 <h4>Callback function</h4>
463 <p>
464 If you specify the <em>callback</em> parameter, it should
465 specify a function that looks like this:
466 </p>
467 <!-- Note: intentionally longer 80 columns -->
468 <pre>function(<span>array of TtsVoice voices</span>) <span cla ss="subdued">{...}</span>;</pre>
469 <dl>
470 <div>
471 <div>
472 <dt>
473 <var>voices</var>
474 <em>
475 <!-- TYPE -->
476 <div style="display:inline">
477 (
478 <span id="typeTemplate">
479 <span>
480 <span>
481 array of <span><span>
482 <span>
483 <a href="tts.html#type-TtsVoice">TtsVoice</a>
484 </span>
485 </span></span>
486 </span>
487 </span>
488 </span>
489 )
490 </div>
491 </em>
492 </dt>
493 <dd>Array of <a href="tts.html#type-TtsVoice">TtsVoice</a> objects rep resenting the available voices for speech synthesis.</dd>
494 <!-- OBJECT PROPERTIES -->
495 <!-- OBJECT METHODS -->
496 <!-- OBJECT EVENT FIELDS -->
497 <!-- FUNCTION PARAMETERS -->
498 </div>
499 </div>
500 </dl>
501 </div>
502 </div>
503 <!-- MIN_VERSION -->
504 </div> <!-- /description -->
505 </div><div class="apiItem">
506 <a name="method-isSpeaking"></a> <!-- method-anchor -->
507 <h4>isSpeaking</h4>
508 <div class="summary">
509 <!-- Note: intentionally longer 80 columns -->
510 <span>chrome.tts.isSpeaking</span>(<span class="optional"><spa n>function</span>
511 <var><span>callback</span></var></span>)</div>
512 <div class="description">
513 <p>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 s peech wasn't initiated by Chrome.</p>
514 <!-- PARAMETERS -->
515 <h4>Parameters</h4>
516 <dl>
517 <div>
518 <div>
519 <dt>
520 <var>callback</var>
521 <em>
522 <!-- TYPE -->
523 <div style="display:inline">
524 (
525 <span class="optional">optional</span>
526 <span id="typeTemplate">
527 <span>
528 <span>function</span>
529 </span>
530 </span>
531 )
532 </div>
533 </em>
534 </dt>
535 <dd class="todo">
536 Undocumented.
537 </dd>
538 <!-- OBJECT PROPERTIES -->
539 <!-- OBJECT METHODS -->
540 <!-- OBJECT EVENT FIELDS -->
541 <!-- FUNCTION PARAMETERS -->
542 </div>
543 </div>
544 </dl>
545 <!-- RETURNS -->
546 <dl>
547 </dl>
548 <!-- CALLBACK -->
549 <div>
550 <div>
551 <h4>Callback function</h4>
552 <p>
553 If you specify the <em>callback</em> parameter, it should
554 specify a function that looks like this:
555 </p>
556 <!-- Note: intentionally longer 80 columns -->
557 <pre>function(<span>boolean speaking</span>) <span class="subd ued">{...}</span>;</pre>
558 <dl>
559 <div>
560 <div>
561 <dt>
562 <var>speaking</var>
563 <em>
564 <!-- TYPE -->
565 <div style="display:inline">
566 (
567 <span id="typeTemplate">
568 <span>
569 <span>boolean</span>
570 </span>
571 </span>
572 )
573 </div>
574 </em>
575 </dt>
576 <dd>True if speaking, false otherwise.</dd>
577 <!-- OBJECT PROPERTIES -->
578 <!-- OBJECT METHODS -->
579 <!-- OBJECT EVENT FIELDS -->
580 <!-- FUNCTION PARAMETERS -->
581 </div>
582 </div>
583 </dl>
584 </div>
585 </div>
586 <!-- MIN_VERSION -->
587 </div> <!-- /description -->
588 </div><div class="apiItem">
589 <a name="method-speak"></a> <!-- method-anchor -->
590 <h4>speak</h4>
591 <div class="summary">
592 <!-- Note: intentionally longer 80 columns -->
593 <span>chrome.tts.speak</span>(<span class="null"><span>string< /span>
594 <var><span>utterance</span></var></span><span class="optio nal"><span>, </span><span>object</span>
595 <var><span>options</span></var></span><span class="optiona l"><span>, </span><span>function</span>
596 <var><span>callback</span></var></span>)</div>
597 <div class="description">
598 <p>Speaks text using a text-to-speech engine.</p>
599 <!-- PARAMETERS -->
600 <h4>Parameters</h4>
601 <dl>
602 <div>
603 <div>
604 <dt>
605 <var>utterance</var>
606 <em>
607 <!-- TYPE -->
608 <div style="display:inline">
609 (
610 <span id="typeTemplate">
611 <span>
612 <span>string</span>
613 </span>
614 </span>
615 )
616 </div>
617 </em>
618 </dt>
619 <dd>The text to speak, either plain text or a complete, well-formed SS ML document. Speech engines that do not support SSML will strip away the tags an d speak the text. The maximum length of the text is 32,768 characters.</dd>
620 <!-- OBJECT PROPERTIES -->
621 <!-- OBJECT METHODS -->
622 <!-- OBJECT EVENT FIELDS -->
623 <!-- FUNCTION PARAMETERS -->
624 </div>
625 </div><div>
626 <div>
627 <dt>
628 <var>options</var>
629 <em>
630 <!-- TYPE -->
631 <div style="display:inline">
632 (
633 <span class="optional">optional</span>
634 <span id="typeTemplate">
635 <span>
636 <span>object</span>
637 </span>
638 </span>
639 )
640 </div>
641 </em>
642 </dt>
643 <dd>The speech options.</dd>
644 <!-- OBJECT PROPERTIES -->
645 <dd>
646 <dl>
647 <div>
648 <div>
649 <dt>
650 <var>enqueue</var>
651 <em>
652 <!-- TYPE -->
653 <div style="display:inline">
654 (
655 <span class="optional">optional</span>
656 <span id="typeTemplate">
657 <span>
658 <span>boolean</span>
659 </span>
660 </span>
661 )
662 </div>
663 </em>
664 </dt>
665 <dd>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.</dd>
666 <!-- OBJECT PROPERTIES -->
667 <!-- OBJECT METHODS -->
668 <!-- OBJECT EVENT FIELDS -->
669 <!-- FUNCTION PARAMETERS -->
670 </div>
671 </div><div>
672 <div>
673 <dt>
674 <var>voiceName</var>
675 <em>
676 <!-- TYPE -->
677 <div style="display:inline">
678 (
679 <span class="optional">optional</span>
680 <span id="typeTemplate">
681 <span>
682 <span>string</span>
683 </span>
684 </span>
685 )
686 </div>
687 </em>
688 </dt>
689 <dd>The name of the voice to use for synthesis. If empty, uses any ava ilable voice.</dd>
690 <!-- OBJECT PROPERTIES -->
691 <!-- OBJECT METHODS -->
692 <!-- OBJECT EVENT FIELDS -->
693 <!-- FUNCTION PARAMETERS -->
694 </div>
695 </div><div>
696 <div>
697 <dt>
698 <var>extensionId</var>
699 <em>
700 <!-- TYPE -->
701 <div style="display:inline">
702 (
703 <span class="optional">optional</span>
704 <span id="typeTemplate">
705 <span>
706 <span>string</span>
707 </span>
708 </span>
709 )
710 </div>
711 </em>
712 </dt>
713 <dd>The extension ID of the speech engine to use, if known.</dd>
714 <!-- OBJECT PROPERTIES -->
715 <!-- OBJECT METHODS -->
716 <!-- OBJECT EVENT FIELDS -->
717 <!-- FUNCTION PARAMETERS -->
718 </div>
719 </div><div>
720 <div>
721 <dt>
722 <var>lang</var>
723 <em>
724 <!-- TYPE -->
725 <div style="display:inline">
726 (
727 <span class="optional">optional</span>
728 <span id="typeTemplate">
729 <span>
730 <span>string</span>
731 </span>
732 </span>
733 )
734 </div>
735 </em>
736 </dt>
737 <dd>The language to be used for synthesis, in the form <em>language</e m>-<em>region</em>. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'.</dd>
738 <!-- OBJECT PROPERTIES -->
739 <!-- OBJECT METHODS -->
740 <!-- OBJECT EVENT FIELDS -->
741 <!-- FUNCTION PARAMETERS -->
742 </div>
743 </div><div>
744 <div>
745 <dt>
746 <var>gender</var>
747 <em>
748 <!-- TYPE -->
749 <div style="display:inline">
750 (
751 <span class="optional">optional</span>
752 <span class="enum">enumerated</span>
753 <span id="typeTemplate">
754 <span>
755 <span>string</span>
756 <span>["male", "female"]</span>
757 </span>
758 </span>
759 )
760 </div>
761 </em>
762 </dt>
763 <dd>Gender of voice for synthesized speech.</dd>
764 <!-- OBJECT PROPERTIES -->
765 <!-- OBJECT METHODS -->
766 <!-- OBJECT EVENT FIELDS -->
767 <!-- FUNCTION PARAMETERS -->
768 </div>
769 </div><div>
770 <div>
771 <dt>
772 <var>rate</var>
773 <em>
774 <!-- TYPE -->
775 <div style="display:inline">
776 (
777 <span class="optional">optional</span>
778 <span id="typeTemplate">
779 <span>
780 <span>number</span>
781 </span>
782 </span>
783 )
784 </div>
785 </em>
786 </dt>
787 <dd>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 f ast, and 0.5 is half as fast. Values below 0.1 or above 10.0 are strictly disall owed, but many voices will constrain the minimum and maximum rates further—for e xample a particular voice may not actually speak faster than 3 times normal even if you specify a value larger than 3.0.</dd>
788 <!-- OBJECT PROPERTIES -->
789 <!-- OBJECT METHODS -->
790 <!-- OBJECT EVENT FIELDS -->
791 <!-- FUNCTION PARAMETERS -->
792 </div>
793 </div><div>
794 <div>
795 <dt>
796 <var>pitch</var>
797 <em>
798 <!-- TYPE -->
799 <div style="display:inline">
800 (
801 <span class="optional">optional</span>
802 <span id="typeTemplate">
803 <span>
804 <span>number</span>
805 </span>
806 </span>
807 )
808 </div>
809 </em>
810 </dt>
811 <dd>Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to a voice's default pitch.</dd>
812 <!-- OBJECT PROPERTIES -->
813 <!-- OBJECT METHODS -->
814 <!-- OBJECT EVENT FIELDS -->
815 <!-- FUNCTION PARAMETERS -->
816 </div>
817 </div><div>
818 <div>
819 <dt>
820 <var>volume</var>
821 <em>
822 <!-- TYPE -->
823 <div style="display:inline">
824 (
825 <span class="optional">optional</span>
826 <span id="typeTemplate">
827 <span>
828 <span>number</span>
829 </span>
830 </span>
831 )
832 </div>
833 </em>
834 </dt>
835 <dd>Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0.</dd>
836 <!-- OBJECT PROPERTIES -->
837 <!-- OBJECT METHODS -->
838 <!-- OBJECT EVENT FIELDS -->
839 <!-- FUNCTION PARAMETERS -->
840 </div>
841 </div><div>
842 <div>
843 <dt>
844 <var>requiredEventTypes</var>
845 <em>
846 <!-- TYPE -->
847 <div style="display:inline">
848 (
849 <span class="optional">optional</span>
850 <span id="typeTemplate">
851 <span>
852 <span>
853 array of <span><span>
854 <span>
855 <span>string</span>
856 </span>
857 </span></span>
858 </span>
859 </span>
860 </span>
861 )
862 </div>
863 </em>
864 </dt>
865 <dd>The TTS event types the voice must support.</dd>
866 <!-- OBJECT PROPERTIES -->
867 <!-- OBJECT METHODS -->
868 <!-- OBJECT EVENT FIELDS -->
869 <!-- FUNCTION PARAMETERS -->
870 </div>
871 </div><div>
872 <div>
873 <dt>
874 <var>desiredEventTypes</var>
875 <em>
876 <!-- TYPE -->
877 <div style="display:inline">
878 (
879 <span class="optional">optional</span>
880 <span id="typeTemplate">
881 <span>
882 <span>
883 array of <span><span>
884 <span>
885 <span>string</span>
886 </span>
887 </span></span>
888 </span>
889 </span>
890 </span>
891 )
892 </div>
893 </em>
894 </dt>
895 <dd>The TTS event types that you are interested in listening to. If mi ssing, all event types may be sent.</dd>
896 <!-- OBJECT PROPERTIES -->
897 <!-- OBJECT METHODS -->
898 <!-- OBJECT EVENT FIELDS -->
899 <!-- FUNCTION PARAMETERS -->
900 </div>
901 </div><div>
902 <div>
903 <dt>
904 <var>onEvent</var>
905 <em>
906 <!-- TYPE -->
907 <div style="display:inline">
908 (
909 <span class="optional">optional</span>
910 <span id="typeTemplate">
911 <span>
912 <span>function</span>
913 </span>
914 </span>
915 )
916 </div>
917 </em>
918 </dt>
919 <dd>This function is called with events that occur in the process of s peaking the utterance.</dd>
920 <!-- OBJECT PROPERTIES -->
921 <!-- OBJECT METHODS -->
922 <!-- OBJECT EVENT FIELDS -->
923 <!-- FUNCTION PARAMETERS -->
924 <dd>
925 <div>
926 <h5>Parameters</h5>
927 <dl>
928 <div>
929 <div>
930 <dt>
931 <var>event</var>
932 <em>
933 <!-- TYPE -->
934 <div style="display:inline">
935 (
936 <span id="typeTemplate">
937 <span>
938 <a href="tts.html#type-TtsEvent">TtsEvent</a>
939 </span>
940 </span>
941 )
942 </div>
943 </em>
944 </dt>
945 <dd>The update event from the text-to-speech engine indicating the sta tus of this utterance.</dd>
946 <!-- OBJECT PROPERTIES -->
947 <!-- OBJECT METHODS -->
948 <!-- OBJECT EVENT FIELDS -->
949 <!-- FUNCTION PARAMETERS -->
950 </div>
951 </div>
952 </dl>
953 </div>
954 </dd>
955 </div>
956 </div>
957 </dl>
958 </dd>
959 <!-- OBJECT METHODS -->
960 <!-- OBJECT EVENT FIELDS -->
961 <!-- FUNCTION PARAMETERS -->
962 </div>
963 </div><div>
964 <div>
965 <dt>
966 <var>callback</var>
967 <em>
968 <!-- TYPE -->
969 <div style="display:inline">
970 (
971 <span class="optional">optional</span>
972 <span id="typeTemplate">
973 <span>
974 <span>function</span>
975 </span>
976 </span>
977 )
978 </div>
979 </em>
980 </dt>
981 <dd>Called right away, before speech finishes. Check chrome.extension. lastError to make sure there were no errors. Use options.onEvent to get more det ailed feedback.</dd>
982 <!-- OBJECT PROPERTIES -->
983 <!-- OBJECT METHODS -->
984 <!-- OBJECT EVENT FIELDS -->
985 <!-- FUNCTION PARAMETERS -->
986 </div>
987 </div>
988 </dl>
989 <!-- RETURNS -->
990 <dl>
991 </dl>
992 <!-- CALLBACK -->
993 <div>
994 <div>
995 <h4>Callback function</h4>
996 <p>
997 If you specify the <em>callback</em> parameter, it should
998 specify a function that looks like this:
999 </p>
1000 <!-- Note: intentionally longer 80 columns -->
1001 <pre>function(<span></span>) <span class="subdued">{...}</span >;</pre>
1002 <dl>
1003 </dl>
1004 </div>
1005 </div>
1006 <!-- MIN_VERSION -->
1007 </div> <!-- /description -->
1008 </div><div class="apiItem">
1009 <a name="method-stop"></a> <!-- method-anchor -->
1010 <h4>stop</h4>
1011 <div class="summary">
1012 <!-- Note: intentionally longer 80 columns -->
1013 <span>chrome.tts.stop</span>()</div>
1014 <div class="description">
1015 <p>Stops any current speech.</p>
1016 <!-- PARAMETERS -->
1017 <dl>
1018 </dl>
1019 <!-- RETURNS -->
1020 <dl>
1021 </dl>
1022 <!-- CALLBACK -->
1023 <!-- MIN_VERSION -->
1024 </div> <!-- /description -->
1025 </div> <!-- /apiItem -->
1026 </div> <!-- /apiGroup -->
1027 <!-- EVENTS -->
1028 <!-- /apiGroup -->
1029 <!-- TYPES -->
1030 <div class="apiGroup">
1031 <a name="types"></a>
1032 <h3 id="types">Types</h3>
1033 <!-- iterates over all types -->
1034 <div class="apiItem">
1035 <a name="type-TtsEvent"></a>
1036 <h4>TtsEvent</h4>
1037 <div>
1038 <dt>
1039 <em>
1040 <!-- TYPE -->
1041 <div style="display:inline">
1042 (
1043 <span id="typeTemplate">
1044 <span>
1045 <span>object</span>
1046 </span>
1047 </span>
1048 )
1049 </div>
1050 </em>
1051 </dt>
1052 <dd>An event from the TTS engine to communicate the status of an utter ance.</dd>
1053 <!-- OBJECT PROPERTIES -->
1054 <dd>
1055 <dl>
1056 <div>
1057 <div>
1058 <dt>
1059 <var>type</var>
1060 <em>
1061 <!-- TYPE -->
1062 <div style="display:inline">
1063 (
1064 <span class="enum">enumerated</span>
1065 <span id="typeTemplate">
1066 <span>
1067 <span>string</span>
1068 <span>["start", "end", "word", "sentence", "marker", "in terrupted", "cancelled", "error"]</span>
1069 </span>
1070 </span>
1071 )
1072 </div>
1073 </em>
1074 </dt>
1075 <dd>The type can be 'start' as soon as speech has started, 'word' when a word boundary is reached, 'sentence' when a sentence boundary is reached, 'ma rker' when an SSML mark element is reached, 'end' when the end of the utterance is reached, 'interrupted' when the utterance is stopped or interrupted before re aching the end, 'cancelled' when it's removed from the queue before ever being s ynthesized, or 'error' when any other error occurs.</dd>
1076 <!-- OBJECT PROPERTIES -->
1077 <!-- OBJECT METHODS -->
1078 <!-- OBJECT EVENT FIELDS -->
1079 <!-- FUNCTION PARAMETERS -->
1080 </div>
1081 </div><div>
1082 <div>
1083 <dt>
1084 <var>charIndex</var>
1085 <em>
1086 <!-- TYPE -->
1087 <div style="display:inline">
1088 (
1089 <span class="optional">optional</span>
1090 <span id="typeTemplate">
1091 <span>
1092 <span>number</span>
1093 </span>
1094 </span>
1095 )
1096 </div>
1097 </em>
1098 </dt>
1099 <dd>The index of the current character in the utterance.</dd>
1100 <!-- OBJECT PROPERTIES -->
1101 <!-- OBJECT METHODS -->
1102 <!-- OBJECT EVENT FIELDS -->
1103 <!-- FUNCTION PARAMETERS -->
1104 </div>
1105 </div><div>
1106 <div>
1107 <dt>
1108 <var>errorMessage</var>
1109 <em>
1110 <!-- TYPE -->
1111 <div style="display:inline">
1112 (
1113 <span class="optional">optional</span>
1114 <span id="typeTemplate">
1115 <span>
1116 <span>string</span>
1117 </span>
1118 </span>
1119 )
1120 </div>
1121 </em>
1122 </dt>
1123 <dd>The error description, if the event type is 'error'.</dd>
1124 <!-- OBJECT PROPERTIES -->
1125 <!-- OBJECT METHODS -->
1126 <!-- OBJECT EVENT FIELDS -->
1127 <!-- FUNCTION PARAMETERS -->
1128 </div>
1129 </div>
1130 </dl>
1131 </dd>
1132 <!-- OBJECT METHODS -->
1133 <!-- OBJECT EVENT FIELDS -->
1134 <!-- FUNCTION PARAMETERS -->
1135 </div>
1136 </div><div class="apiItem">
1137 <a name="type-TtsVoice"></a>
1138 <h4>TtsVoice</h4>
1139 <div>
1140 <dt>
1141 <em>
1142 <!-- TYPE -->
1143 <div style="display:inline">
1144 (
1145 <span id="typeTemplate">
1146 <span>
1147 <span>object</span>
1148 </span>
1149 </span>
1150 )
1151 </div>
1152 </em>
1153 </dt>
1154 <dd>A description of a voice available for speech synthesis.</dd>
1155 <!-- OBJECT PROPERTIES -->
1156 <dd>
1157 <dl>
1158 <div>
1159 <div>
1160 <dt>
1161 <var>voiceName</var>
1162 <em>
1163 <!-- TYPE -->
1164 <div style="display:inline">
1165 (
1166 <span class="optional">optional</span>
1167 <span id="typeTemplate">
1168 <span>
1169 <span>string</span>
1170 </span>
1171 </span>
1172 )
1173 </div>
1174 </em>
1175 </dt>
1176 <dd>The name of the voice.</dd>
1177 <!-- OBJECT PROPERTIES -->
1178 <!-- OBJECT METHODS -->
1179 <!-- OBJECT EVENT FIELDS -->
1180 <!-- FUNCTION PARAMETERS -->
1181 </div>
1182 </div><div>
1183 <div>
1184 <dt>
1185 <var>lang</var>
1186 <em>
1187 <!-- TYPE -->
1188 <div style="display:inline">
1189 (
1190 <span class="optional">optional</span>
1191 <span id="typeTemplate">
1192 <span>
1193 <span>string</span>
1194 </span>
1195 </span>
1196 )
1197 </div>
1198 </em>
1199 </dt>
1200 <dd>The language that this voice supports, in the form <em>language</e m>-<em>region</em>. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'.</dd>
1201 <!-- OBJECT PROPERTIES -->
1202 <!-- OBJECT METHODS -->
1203 <!-- OBJECT EVENT FIELDS -->
1204 <!-- FUNCTION PARAMETERS -->
1205 </div>
1206 </div><div>
1207 <div>
1208 <dt>
1209 <var>gender</var>
1210 <em>
1211 <!-- TYPE -->
1212 <div style="display:inline">
1213 (
1214 <span class="optional">optional</span>
1215 <span class="enum">enumerated</span>
1216 <span id="typeTemplate">
1217 <span>
1218 <span>string</span>
1219 <span>["male", "female"]</span>
1220 </span>
1221 </span>
1222 )
1223 </div>
1224 </em>
1225 </dt>
1226 <dd>This voice's gender.</dd>
1227 <!-- OBJECT PROPERTIES -->
1228 <!-- OBJECT METHODS -->
1229 <!-- OBJECT EVENT FIELDS -->
1230 <!-- FUNCTION PARAMETERS -->
1231 </div>
1232 </div><div>
1233 <div>
1234 <dt>
1235 <var>extensionId</var>
1236 <em>
1237 <!-- TYPE -->
1238 <div style="display:inline">
1239 (
1240 <span class="optional">optional</span>
1241 <span id="typeTemplate">
1242 <span>
1243 <span>string</span>
1244 </span>
1245 </span>
1246 )
1247 </div>
1248 </em>
1249 </dt>
1250 <dd>The ID of the extension providing this voice.</dd>
1251 <!-- OBJECT PROPERTIES -->
1252 <!-- OBJECT METHODS -->
1253 <!-- OBJECT EVENT FIELDS -->
1254 <!-- FUNCTION PARAMETERS -->
1255 </div>
1256 </div><div>
1257 <div>
1258 <dt>
1259 <var>eventTypes</var>
1260 <em>
1261 <!-- TYPE -->
1262 <div style="display:inline">
1263 (
1264 <span class="optional">optional</span>
1265 <span id="typeTemplate">
1266 <span>
1267 <span>
1268 array of <span><span>
1269 <span>
1270 <span>string</span>
1271 </span>
1272 </span></span>
1273 </span>
1274 </span>
1275 </span>
1276 )
1277 </div>
1278 </em>
1279 </dt>
1280 <dd>All of the callback event types that this voice is capable of send ing.</dd>
1281 <!-- OBJECT PROPERTIES -->
1282 <!-- OBJECT METHODS -->
1283 <!-- OBJECT EVENT FIELDS -->
1284 <!-- FUNCTION PARAMETERS -->
1285 </div>
1286 </div>
1287 </dl>
1288 </dd>
1289 <!-- OBJECT METHODS -->
1290 <!-- OBJECT EVENT FIELDS -->
1291 <!-- FUNCTION PARAMETERS -->
1292 </div>
1293 </div> <!-- /apiItem -->
1294 </div> <!-- /apiGroup -->
1295 </div> <!-- /apiPage -->
1296 </div> <!-- /gc-pagecontent -->
1297 </div> <!-- /g-section -->
1298 </div> <!-- /codesiteContent -->
1299 <div id="gc-footer" --="">
1300 <div class="text">
1301 <p>
1302 Except as otherwise <a href="http://code.google.com/policies.html#restrictions ">noted</a>,
1303 the content of this page is licensed under the <a rel="license" href="http://c reativecommons.org/licenses/by/3.0/">Creative Commons
1304 Attribution 3.0 License</a>, and code samples are licensed under the
1305 <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD Lic ense</a>.
1306 </p>
1307 <p>
1308 ©2011 Google
1309 </p>
1310 <!-- begin analytics -->
1311 <script src="https://www.google-analytics.com/urchin.js" type="text/javascript"> </script>
1312 <script src="https://www.google-analytics.com/ga.js" type="text/javascript"></sc ript>
1313 <script type="text/javascript">
1314 // chrome doc tracking
1315 try {
1316 var engdocs = _gat._getTracker("YT-10763712-2");
1317 engdocs._trackPageview();
1318 } catch(err) {}
1319 // code.google.com site-wide tracking
1320 try {
1321 _uacct="UA-18071-1";
1322 _uanchor=1;
1323 _uff=0;
1324 urchinTracker();
1325 }
1326 catch(e) {/* urchinTracker not available. */}
1327 </script>
1328 <!-- end analytics -->
1329 </div>
1330 </div> <!-- /gc-footer -->
1331 </div> <!-- /gc-container -->
1332 </body></html>
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/topSites.html ('k') | chrome/common/extensions/docs/ttsEngine.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698