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

Side by Side Diff: chrome/browser/speech/tts_controller.h

Issue 15108002: Add Pause and Resume to Web TTS & Extension TTS APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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
« no previous file with comments | « chrome/browser/speech/tts_chromeos.cc ('k') | chrome/browser/speech/tts_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_
6 #define CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ 6 #define CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 13 matching lines...) Expand all
24 24
25 // Events sent back from the TTS engine indicating the progress. 25 // Events sent back from the TTS engine indicating the progress.
26 enum TtsEventType { 26 enum TtsEventType {
27 TTS_EVENT_START, 27 TTS_EVENT_START,
28 TTS_EVENT_END, 28 TTS_EVENT_END,
29 TTS_EVENT_WORD, 29 TTS_EVENT_WORD,
30 TTS_EVENT_SENTENCE, 30 TTS_EVENT_SENTENCE,
31 TTS_EVENT_MARKER, 31 TTS_EVENT_MARKER,
32 TTS_EVENT_INTERRUPTED, 32 TTS_EVENT_INTERRUPTED,
33 TTS_EVENT_CANCELLED, 33 TTS_EVENT_CANCELLED,
34 TTS_EVENT_ERROR 34 TTS_EVENT_ERROR,
35 TTS_EVENT_PAUSE,
36 TTS_EVENT_RESUME
35 }; 37 };
36 38
37 enum TtsGenderType { 39 enum TtsGenderType {
38 TTS_GENDER_NONE, 40 TTS_GENDER_NONE,
39 TTS_GENDER_MALE, 41 TTS_GENDER_MALE,
40 TTS_GENDER_FEMALE 42 TTS_GENDER_FEMALE
41 }; 43 };
42 44
43 // Returns true if this event type is one that indicates an utterance 45 // Returns true if this event type is one that indicates an utterance
44 // is finished and can be destroyed. 46 // is finished and can be destroyed.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 246
245 // Returns true if we're currently speaking an utterance. 247 // Returns true if we're currently speaking an utterance.
246 bool IsSpeaking(); 248 bool IsSpeaking();
247 249
248 // Speak the given utterance. If the utterance's can_enqueue flag is true 250 // Speak the given utterance. If the utterance's can_enqueue flag is true
249 // and another utterance is in progress, adds it to the end of the queue. 251 // and another utterance is in progress, adds it to the end of the queue.
250 // Otherwise, interrupts any current utterance and speaks this one 252 // Otherwise, interrupts any current utterance and speaks this one
251 // immediately. 253 // immediately.
252 void SpeakOrEnqueue(Utterance* utterance); 254 void SpeakOrEnqueue(Utterance* utterance);
253 255
254 // Stop all utterances and flush the queue. 256 // Stop all utterances and flush the queue. Implies leaving pause mode
257 // as well.
255 void Stop(); 258 void Stop();
256 259
260 // Pause the speech queue. Some engines may support pausing in the middle
261 // of an utterance.
262 void Pause();
263
264 // Resume speaking.
265 void Resume();
266
257 // Handle events received from the speech engine. Events are forwarded to 267 // Handle events received from the speech engine. Events are forwarded to
258 // the callback function, and in addition, completion and error events 268 // the callback function, and in addition, completion and error events
259 // trigger finishing the current utterance and starting the next one, if 269 // trigger finishing the current utterance and starting the next one, if
260 // any. 270 // any.
261 void OnTtsEvent(int utterance_id, 271 void OnTtsEvent(int utterance_id,
262 TtsEventType event_type, 272 TtsEventType event_type,
263 int char_index, 273 int char_index,
264 const std::string& error_message); 274 const std::string& error_message);
265 275
266 // Return a list of all available voices, including the native voice, 276 // Return a list of all available voices, including the native voice,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // Given an utterance and a vector of voices, return the 320 // Given an utterance and a vector of voices, return the
311 // index of the voice that best matches the utterance. 321 // index of the voice that best matches the utterance.
312 int GetMatchingVoice(const Utterance* utterance, 322 int GetMatchingVoice(const Utterance* utterance,
313 std::vector<VoiceData>& voices); 323 std::vector<VoiceData>& voices);
314 324
315 friend struct DefaultSingletonTraits<TtsController>; 325 friend struct DefaultSingletonTraits<TtsController>;
316 326
317 // The current utterance being spoken. 327 // The current utterance being spoken.
318 Utterance* current_utterance_; 328 Utterance* current_utterance_;
319 329
330 // Whether the queue is paused or not.
331 bool paused_;
332
320 // A queue of utterances to speak after the current one finishes. 333 // A queue of utterances to speak after the current one finishes.
321 std::queue<Utterance*> utterance_queue_; 334 std::queue<Utterance*> utterance_queue_;
322 335
323 // A set of delegates that want to be notified when the voices change. 336 // A set of delegates that want to be notified when the voices change.
324 std::set<VoicesChangedDelegate*> voices_changed_delegates_; 337 std::set<VoicesChangedDelegate*> voices_changed_delegates_;
325 338
326 // A pointer to the platform implementation of text-to-speech, for 339 // A pointer to the platform implementation of text-to-speech, for
327 // dependency injection. 340 // dependency injection.
328 TtsPlatformImpl* platform_impl_; 341 TtsPlatformImpl* platform_impl_;
329 342
330 DISALLOW_COPY_AND_ASSIGN(TtsController); 343 DISALLOW_COPY_AND_ASSIGN(TtsController);
331 }; 344 };
332 345
333 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ 346 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/speech/tts_chromeos.cc ('k') | chrome/browser/speech/tts_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698