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

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

Issue 7282048: Update TTS extension API docs to reflect latest changes. Note that this (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
OLDNEW
1 <p id="classSummary"> 1 <p id="classSummary">
2 Use the <code>chrome.experimental.ttsEngine</code> module to 2 Use the <code>chrome.experimental.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 the intended utterance 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="experimental.tts.html">experimental.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
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 ] 57 ]
58 },</b> 58 },</b>
59 "background_page": "background.html", 59 "background_page": "background.html",
60 }</pre> 60 }</pre>
61 61
62 <p>An extension can specify any number of voices.</p> 62 <p>An extension can specify any number of voices.</p>
63 63
64 <p>The <code>voice_name</code> parameter is required. The name should be 64 <p>The <code>voice_name</code> parameter is required. The name should be
65 descriptive enough that it identifies the name of the voice and the 65 descriptive enough that it identifies the name of the voice and the
66 engine used. In the unlikely event that two extensions register voices 66 engine used. In the unlikely event that two extensions register voices
67 with the same name, a client can manually specify the extension id it 67 with the same name, a client can specify the ID of the extension that
68 wants to do the synthesis.</p> 68 should do the synthesis.</p>
69 69
70 <p>The <code>gender</code> parameter is optional. If your voice corresponds 70 <p>The <code>gender</code> parameter is optional. If your voice corresponds
71 to a male or female voice, you can use this parameter to help clients 71 to a male or female voice, you can use this parameter to help clients
72 choose the most appropriate voice for their application.</p> 72 choose the most appropriate voice for their application.</p>
73 73
74 <p>The <code>lang</code> parameter is optional, but highly recommended. 74 <p>The <code>lang</code> parameter is optional, but highly recommended.
75 Almost always, a voice can synthesize speech in just a single language. 75 Almost always, a voice can synthesize speech in just a single language.
76 When an engine supports more than one language, it can easily register a 76 When an engine supports more than one language, it can easily register a
77 separate voice for each language. Under rare circumstances where a single 77 separate voice for each language. Under rare circumstances where a single
78 voice can handle more than one language, it's easiest to just list two 78 voice can handle more than one language, it's easiest to just list two
79 separate voices and handle them using the same logic internally. However, 79 separate voices and handle them using the same logic internally. However,
80 if you want to create a voice that will handle utterances in any language, 80 if you want to create a voice that will handle utterances in any language,
81 leave out the <code>lang</code> parameter from your extension's manifest.</p> 81 leave out the <code>lang</code> parameter from your extension's manifest.</p>
82 82
83 <p>Finally, the <code>event_types</code> parameter is required if the engine can 83 <p>Finally, the <code>event_types</code> parameter is required if the engine can
84 send events to update the client on the progress of speech synthesis. 84 send events to update the client on the progress of speech synthesis.
85 At a minimum, supporting the <code>'end'</code> event type to indicate 85 At a minimum, supporting the <code>'end'</code> event type to indicate
86 when speech is finished is highly recommend, otherwise it's impossible 86 when speech is finished is highly recommended, otherwise Chrome cannot
87 for Chrome to schedule queued utterances.</p> 87 schedule queued utterances.</p>
88 88
89 <p class="note">If your TTS engine does not support the <code>'end'</code> 89 <p class="note">
90 event type, Chrome will pass the <code>enqueue</code> option to 90 <strong>Note:</strong> If your TTS engine does not support
91 onSpeak, so that your engine can implement its own queuing. However, this is 91 the <code>'end'</code> event type, Chrome cannot queue utterances
92 discouraged because it means that users cannot queue utterances that get 92 because it has no way of knowing when your utterance has finished. To
93 sent to different speech engines.</p> 93 help mitigate this, Chrome passes an additional boolean <code>enqueue</code>
94 option to your engine's onSpeak handler, giving you the option of
95 implementing your own queueing. This is discouraged because then
96 clients are unable to queue utterances that should get spoken by different
97 speech engines.</p>
94 98
95 <p>The possible event types you can send correspond to the event types that 99 <p>The possible event types that you can send correspond to the event types
96 the <code>speak()</code> method receives:</p> 100 that the <code>speak()</code> method receives:</p>
97 101
98 <ul> 102 <ul>
99 <li><code>'start'</code>: the engine has started speaking the utterance. 103 <li><code>'start'</code>: The engine has started speaking the utterance.
100 <li><code>'word'</code>: a word boundary was reached. Use 104 <li><code>'word'</code>: A word boundary was reached. Use
101 <code>event.charIndex</code> to determine the current speech 105 <code>event.charIndex</code> to determine the current speech
102 position. 106 position.
103 <li><code>'sentence'</code>: a sentence boundary was reached. Use 107 <li><code>'sentence'</code>: A sentence boundary was reached. Use
104 <code>event.charIndex</code> to determine the current speech 108 <code>event.charIndex</code> to determine the current speech
105 position. 109 position.
106 <li><code>'marker'</code>: an SSML marker was reached. Use 110 <li><code>'marker'</code>: An SSML marker was reached. Use
107 <code>event.charIndex</code> to determine the current speech 111 <code>event.charIndex</code> to determine the current speech
108 position. 112 position.
109 <li><code>'end'</code>: the engine has finished speaking the utterance. 113 <li><code>'end'</code>: The engine has finished speaking the utterance.
110 <li><code>'error'</code>: An engine-specific error occurred and 114 <li><code>'error'</code>: An engine-specific error occurred and
111 this utterance cannot be spoken. 115 this utterance cannot be spoken.
112 Pass more information in <code>event.errorMessage</code>. 116 Pass more information in <code>event.errorMessage</code>.
113 </ul> 117 </ul>
114 118
115 <p>The <code>'interrupted'</code> and <code>'cancelled'</code> events are 119 <p>The <code>'interrupted'</code> and <code>'cancelled'</code> events are
116 not sent by the speech engine; they are generated automatically by Chrome.</p> 120 not sent by the speech engine; they are generated automatically by Chrome.</p>
117 121
118 <p>The information about your extensions's voices from your manifest 122 <p>Text-to-speech clients can get the voice information from your
119 will be returned to any client that calls <code>getVoices</code>, assuming 123 extension's manifest by calling
120 you've also registered speech event listeners as described below.</p> 124 <a href="experimental.tts.html#method-getVoices">getVoices()</a>,
125 assuming you've registered speech event listeners as described below.</p>
121 126
122 <h2 id="handling_speech_events">Handling Speech Events</h2> 127 <h2 id="handling_speech_events">Handling speech events</h2>
123 128
124 <p>To generate speech at the request of clients, your extension must 129 <p>To generate speech at the request of clients, your extension must
125 register listeners for both <code>onSpeak</code> and <code>onStop</code>, 130 register listeners for both <code>onSpeak</code> and <code>onStop</code>,
126 like this:</p> 131 like this:</p>
127 132
128 <pre>var speakListener = function(utterance, options, sendTtsEvent) { 133 <pre>var speakListener = function(utterance, options, sendTtsEvent) {
129 sendTtsEvent({'event_type': 'start', 'charIndex': 0}) 134 sendTtsEvent({'event_type': 'start', 'charIndex': 0})
130 135
131 // (start speaking) 136 // (start speaking)
132 137
133 sendTtsEvent({'event_type': 'end', 'charIndex': utterance.length}) 138 sendTtsEvent({'event_type': 'end', 'charIndex': utterance.length})
134 }; 139 };
135 140
136 var stopListener = function() { 141 var stopListener = function() {
137 // (stop all speech) 142 // (stop all speech)
138 }; 143 };
139 144
140 chrome.experimental.ttsEngine.onSpeak.addListener(speakListener); 145 chrome.experimental.ttsEngine.onSpeak.addListener(speakListener);
141 chrome.experimental.ttsEngine.onStop.addListener(stopListener);</pre> 146 chrome.experimental.ttsEngine.onStop.addListener(stopListener);</pre>
142 147
143 <p class="warning">If an extension does not register listeners for both 148 <p class="warning">
149 <b>Important:</b>
150 If your extension does not register listeners for both
144 <code>onSpeak</code> and <code>onStop</code>, it will not intercept any 151 <code>onSpeak</code> and <code>onStop</code>, it will not intercept any
145 speech calls, regardless of what is in the manifest.</p> 152 speech calls, regardless of what is in the manifest.</p>
146 153
147 <p>The decision of whether or not to send a given speech request to an 154 <p>The decision of whether or not to send a given speech request to an
148 extension is based solely on whether the extension supports the given voice 155 extension is based solely on whether the extension supports the given voice
149 parameters in its manifest and has registered listeners 156 parameters in its manifest and has registered listeners
150 for <code>onSpeak</code> and <code>onStop</code>. In other words, 157 for <code>onSpeak</code> and <code>onStop</code>. In other words,
151 there's no way for an extension to receive a speech request and 158 there's no way for an extension to receive a speech request and
152 dynamically decide whether to handle it or not.</p> 159 dynamically decide whether to handle it.</p>
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/static/experimental.tts.html ('k') | chrome/renderer/resources/extension_process_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698