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

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: Fix typo Created 7 years, 7 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 // 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 238
237 // Returns true if we're currently speaking an utterance. 239 // Returns true if we're currently speaking an utterance.
238 bool IsSpeaking(); 240 bool IsSpeaking();
239 241
240 // Speak the given utterance. If the utterance's can_enqueue flag is true 242 // Speak the given utterance. If the utterance's can_enqueue flag is true
241 // and another utterance is in progress, adds it to the end of the queue. 243 // and another utterance is in progress, adds it to the end of the queue.
242 // Otherwise, interrupts any current utterance and speaks this one 244 // Otherwise, interrupts any current utterance and speaks this one
243 // immediately. 245 // immediately.
244 void SpeakOrEnqueue(Utterance* utterance); 246 void SpeakOrEnqueue(Utterance* utterance);
245 247
246 // Stop all utterances and flush the queue. 248 // Stop all utterances and flush the queue. Implies leaving pause mode
249 // as well.
247 void Stop(); 250 void Stop();
248 251
252 // Pause the speech queue. Some engines may support pausing in the middle
253 // of an utterance.
254 void Pause();
255
256 // Resume speaking.
257 void Resume();
258
249 // Handle events received from the speech engine. Events are forwarded to 259 // Handle events received from the speech engine. Events are forwarded to
250 // the callback function, and in addition, completion and error events 260 // the callback function, and in addition, completion and error events
251 // trigger finishing the current utterance and starting the next one, if 261 // trigger finishing the current utterance and starting the next one, if
252 // any. 262 // any.
253 void OnTtsEvent(int utterance_id, 263 void OnTtsEvent(int utterance_id,
254 TtsEventType event_type, 264 TtsEventType event_type,
255 int char_index, 265 int char_index,
256 const std::string& error_message); 266 const std::string& error_message);
257 267
258 // Return a list of all available voices, including the native voice, 268 // Return a list of all available voices, including the native voice,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Given an utterance and a vector of voices, return the 302 // Given an utterance and a vector of voices, return the
293 // index of the voice that best matches the utterance. 303 // index of the voice that best matches the utterance.
294 int GetMatchingVoice(const Utterance* utterance, 304 int GetMatchingVoice(const Utterance* utterance,
295 std::vector<VoiceData>& voices); 305 std::vector<VoiceData>& voices);
296 306
297 friend struct DefaultSingletonTraits<TtsController>; 307 friend struct DefaultSingletonTraits<TtsController>;
298 308
299 // The current utterance being spoken. 309 // The current utterance being spoken.
300 Utterance* current_utterance_; 310 Utterance* current_utterance_;
301 311
312 // Whether the queue is paused or not.
313 bool paused_;
314
302 // A queue of utterances to speak after the current one finishes. 315 // A queue of utterances to speak after the current one finishes.
303 std::queue<Utterance*> utterance_queue_; 316 std::queue<Utterance*> utterance_queue_;
304 317
305 // A pointer to the platform implementation of text-to-speech, for 318 // A pointer to the platform implementation of text-to-speech, for
306 // dependency injection. 319 // dependency injection.
307 TtsPlatformImpl* platform_impl_; 320 TtsPlatformImpl* platform_impl_;
308 321
309 DISALLOW_COPY_AND_ASSIGN(TtsController); 322 DISALLOW_COPY_AND_ASSIGN(TtsController);
310 }; 323 };
311 324
312 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ 325 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698