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

Side by Side Diff: chrome/common/extensions/docs/static/ttsEngine.html

Issue 7258007: Move the tts and ttsEngine APIs out of experimental, and give (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
« no previous file with comments | « chrome/common/extensions/docs/static/tts.html ('k') | chrome/common/extensions/docs/tts.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <p id="classSummary"> 1 <p id="classSummary">
2 Use the <code>chrome.experimental.ttsEngine</code> module to 2 Use the <code>chrome.ttsEngine</code> module to
3 implement a text-to-speech (TTS) engine using an extension. If your 3 implement a text-to-speech (TTS) engine using an extension. If your
4 extension registers using this API, it will receive events containing 4 extension registers using this API, it will receive events containing
5 an utterance to be spoken and other parameters when any extension or packaged 5 an utterance to be spoken and other parameters when any extension or packaged
6 app uses the 6 app uses the
7 <a href="experimental.tts.html">experimental.tts</a> 7 <a href="tts.html">tts</a>
8 module to generate speech. Your extension can then use any available 8 module to generate speech. Your extension can then use any available
9 web technology to synthesize and output the speech, and send events back 9 web technology to synthesize and output the speech, and send events back
10 to the calling function to report the status. 10 to the calling function to report the status.
11 </p> 11 </p>
12 12
13 <p class="note"><b>Give us feedback:</b> If you have suggestions, 13 <p class="note"><b>Give us feedback:</b> If you have suggestions,
14 especially changes that should be made before stabilizing the first 14 especially changes that should be made before stabilizing the first
15 version of this API, please send your ideas to the 15 version of this API, please send your ideas to the
16 <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions">chro mium-extensions</a> 16 <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions">chro mium-extensions</a>
17 group.</p> 17 group.</p>
18 18
19 <h2 id="overview">Overview</h2> 19 <h2 id="overview">Overview</h2>
20 20
21 <p>To enable this experimental API, visit
22 <b>chrome://flags</b> and enable <b>Experimental Extension APIs</b>.
23
24 <p>An extension can register itself as a speech engine. By doing so, it 21 <p>An extension can register itself as a speech engine. By doing so, it
25 can intercept some or all calls to functions such as 22 can intercept some or all calls to functions such as
26 <a href="experimental.tts.html#method-speak"><code>speak()</code></a> and 23 <a href="tts.html#method-speak"><code>speak()</code></a> and
27 <a href="experimental.tts.html#method-stop"><code>stop()</code></a> 24 <a href="tts.html#method-stop"><code>stop()</code></a>
28 and provide an alternate implementation. 25 and provide an alternate implementation.
29 Extensions are free to use any available web technology 26 Extensions are free to use any available web technology
30 to provide speech, including streaming audio from a server, HTML5 audio, 27 to provide speech, including streaming audio from a server, HTML5 audio,
31 Native Client, or Flash. An extension could even do something different 28 Native Client, or Flash. An extension could even do something different
32 with the utterances, like display closed captions in a pop-up window or 29 with the utterances, like display closed captions in a pop-up window or
33 send them as log messages to a remote server.</p> 30 send them as log messages to a remote server.</p>
34 31
35 <h2 id="manifest">Manifest</h2> 32 <h2 id="manifest">Manifest</h2>
36 33
37 <p>To implement a TTS engine, an extension must first declare all voices 34 <p>To implement a TTS engine, an extension must
35 declare the "ttsEngine" permission and then declare all voices
38 it provides in the extension manifest, like this:</p> 36 it provides in the extension manifest, like this:</p>
39 37
40 <pre>{ 38 <pre>{
41 "name": "My TTS Engine", 39 "name": "My TTS Engine",
42 "version": "1.0", 40 "version": "1.0",
43 <b>"permissions": ["experimental"], 41 <b>"permissions": ["ttsEngine"],
44 "tts_engine": { 42 "tts_engine": {
45 "voices": [ 43 "voices": [
46 { 44 {
47 "voice_name": "Alice", 45 "voice_name": "Alice",
48 "lang": "en-US", 46 "lang": "en-US",
49 "gender": "female", 47 "gender": "female",
50 "event_types": ["start", "marker", "end"] 48 "event_types": ["start", "marker", "end"]
51 }, 49 },
52 { 50 {
53 "voice_name": "Pat", 51 "voice_name": "Pat",
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 <li><code>'error'</code>: An engine-specific error occurred and 112 <li><code>'error'</code>: An engine-specific error occurred and
115 this utterance cannot be spoken. 113 this utterance cannot be spoken.
116 Pass more information in <code>event.errorMessage</code>. 114 Pass more information in <code>event.errorMessage</code>.
117 </ul> 115 </ul>
118 116
119 <p>The <code>'interrupted'</code> and <code>'cancelled'</code> events are 117 <p>The <code>'interrupted'</code> and <code>'cancelled'</code> events are
120 not sent by the speech engine; they are generated automatically by Chrome.</p> 118 not sent by the speech engine; they are generated automatically by Chrome.</p>
121 119
122 <p>Text-to-speech clients can get the voice information from your 120 <p>Text-to-speech clients can get the voice information from your
123 extension's manifest by calling 121 extension's manifest by calling
124 <a href="experimental.tts.html#method-getVoices">getVoices()</a>, 122 <a href="tts.html#method-getVoices">getVoices()</a>,
125 assuming you've registered speech event listeners as described below.</p> 123 assuming you've registered speech event listeners as described below.</p>
126 124
127 <h2 id="handling_speech_events">Handling speech events</h2> 125 <h2 id="handling_speech_events">Handling speech events</h2>
128 126
129 <p>To generate speech at the request of clients, your extension must 127 <p>To generate speech at the request of clients, your extension must
130 register listeners for both <code>onSpeak</code> and <code>onStop</code>, 128 register listeners for both <code>onSpeak</code> and <code>onStop</code>,
131 like this:</p> 129 like this:</p>
132 130
133 <pre>var speakListener = function(utterance, options, sendTtsEvent) { 131 <pre>var speakListener = function(utterance, options, sendTtsEvent) {
134 sendTtsEvent({'event_type': 'start', 'charIndex': 0}) 132 sendTtsEvent({'event_type': 'start', 'charIndex': 0})
135 133
136 // (start speaking) 134 // (start speaking)
137 135
138 sendTtsEvent({'event_type': 'end', 'charIndex': utterance.length}) 136 sendTtsEvent({'event_type': 'end', 'charIndex': utterance.length})
139 }; 137 };
140 138
141 var stopListener = function() { 139 var stopListener = function() {
142 // (stop all speech) 140 // (stop all speech)
143 }; 141 };
144 142
145 chrome.experimental.ttsEngine.onSpeak.addListener(speakListener); 143 chrome.ttsEngine.onSpeak.addListener(speakListener);
146 chrome.experimental.ttsEngine.onStop.addListener(stopListener);</pre> 144 chrome.ttsEngine.onStop.addListener(stopListener);</pre>
147 145
148 <p class="warning"> 146 <p class="warning">
149 <b>Important:</b> 147 <b>Important:</b>
150 If your extension does not register listeners for both 148 If your extension does not register listeners for both
151 <code>onSpeak</code> and <code>onStop</code>, it will not intercept any 149 <code>onSpeak</code> and <code>onStop</code>, it will not intercept any
152 speech calls, regardless of what is in the manifest.</p> 150 speech calls, regardless of what is in the manifest.</p>
153 151
154 <p>The decision of whether or not to send a given speech request to an 152 <p>The decision of whether or not to send a given speech request to an
155 extension is based solely on whether the extension supports the given voice 153 extension is based solely on whether the extension supports the given voice
156 parameters in its manifest and has registered listeners 154 parameters in its manifest and has registered listeners
157 for <code>onSpeak</code> and <code>onStop</code>. In other words, 155 for <code>onSpeak</code> and <code>onStop</code>. In other words,
158 there's no way for an extension to receive a speech request and 156 there's no way for an extension to receive a speech request and
159 dynamically decide whether to handle it.</p> 157 dynamically decide whether to handle it.</p>
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/static/tts.html ('k') | chrome/common/extensions/docs/tts.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698