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

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

Issue 15012027: Android implementation of text-to-speech code for Web Speech Synthesis API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tts_multivoice
Patch Set: Fix clang error 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
« no previous file with comments | « chrome/browser/speech/tts_android.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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Class that wants to receive events on utterances. 73 // Class that wants to receive events on utterances.
74 class UtteranceEventDelegate { 74 class UtteranceEventDelegate {
75 public: 75 public:
76 virtual ~UtteranceEventDelegate() {} 76 virtual ~UtteranceEventDelegate() {}
77 virtual void OnTtsEvent(Utterance* utterance, 77 virtual void OnTtsEvent(Utterance* utterance,
78 TtsEventType event_type, 78 TtsEventType event_type,
79 int char_index, 79 int char_index,
80 const std::string& error_message) = 0; 80 const std::string& error_message) = 0;
81 }; 81 };
82 82
83 // Class that wants to be notified when the set of
84 // voices has changed.
85 class VoicesChangedDelegate {
86 public:
87 virtual ~VoicesChangedDelegate() {}
88 virtual void OnVoicesChanged() = 0;
89 };
90
83 // One speech utterance. 91 // One speech utterance.
84 class Utterance { 92 class Utterance {
85 public: 93 public:
86 // Construct an utterance given a profile and a completion task to call 94 // Construct an utterance given a profile and a completion task to call
87 // when the utterance is done speaking. Before speaking this utterance, 95 // when the utterance is done speaking. Before speaking this utterance,
88 // its other parameters like text, rate, pitch, etc. should all be set. 96 // its other parameters like text, rate, pitch, etc. should all be set.
89 explicit Utterance(Profile* profile); 97 explicit Utterance(Profile* profile);
90 ~Utterance(); 98 ~Utterance();
91 99
92 // Sends an event to the delegate. If the event type is TTS_EVENT_END 100 // Sends an event to the delegate. If the event type is TTS_EVENT_END
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 const std::string& error_message); 264 const std::string& error_message);
257 265
258 // Return a list of all available voices, including the native voice, 266 // Return a list of all available voices, including the native voice,
259 // if supported, and all voices registered by extensions. 267 // if supported, and all voices registered by extensions.
260 void GetVoices(Profile* profile, std::vector<VoiceData>* out_voices); 268 void GetVoices(Profile* profile, std::vector<VoiceData>* out_voices);
261 269
262 // Called by TtsExtensionLoaderChromeOs::LoadTtsExtension when it 270 // Called by TtsExtensionLoaderChromeOs::LoadTtsExtension when it
263 // finishes loading the built-in TTS component extension. 271 // finishes loading the built-in TTS component extension.
264 void RetrySpeakingQueuedUtterances(); 272 void RetrySpeakingQueuedUtterances();
265 273
274 // Called by the extension system or platform implementation when the
275 // list of voices may have changed and should be re-queried.
276 void VoicesChanged();
277
278 // Add a delegate that wants to be notified when the set of voices changes.
279 void AddVoicesChangedDelegate(VoicesChangedDelegate* delegate);
280
281 // Remove delegate that wants to be notified when the set of voices changes.
282 void RemoveVoicesChangedDelegate(VoicesChangedDelegate* delegate);
283
266 // For unit testing. 284 // For unit testing.
267 void SetPlatformImpl(TtsPlatformImpl* platform_impl); 285 void SetPlatformImpl(TtsPlatformImpl* platform_impl);
268 int QueueSize(); 286 int QueueSize();
269 287
270 protected: 288 protected:
271 TtsController(); 289 TtsController();
272 virtual ~TtsController(); 290 virtual ~TtsController();
273 291
274 private: 292 private:
275 // Get the platform TTS implementation (or injected mock). 293 // Get the platform TTS implementation (or injected mock).
(...skipping 19 matching lines...) Expand all
295 std::vector<VoiceData>& voices); 313 std::vector<VoiceData>& voices);
296 314
297 friend struct DefaultSingletonTraits<TtsController>; 315 friend struct DefaultSingletonTraits<TtsController>;
298 316
299 // The current utterance being spoken. 317 // The current utterance being spoken.
300 Utterance* current_utterance_; 318 Utterance* current_utterance_;
301 319
302 // A queue of utterances to speak after the current one finishes. 320 // A queue of utterances to speak after the current one finishes.
303 std::queue<Utterance*> utterance_queue_; 321 std::queue<Utterance*> utterance_queue_;
304 322
323 // A set of delegates that want to be notified when the voices change.
324 std::set<VoicesChangedDelegate*> voices_changed_delegates_;
325
305 // A pointer to the platform implementation of text-to-speech, for 326 // A pointer to the platform implementation of text-to-speech, for
306 // dependency injection. 327 // dependency injection.
307 TtsPlatformImpl* platform_impl_; 328 TtsPlatformImpl* platform_impl_;
308 329
309 DISALLOW_COPY_AND_ASSIGN(TtsController); 330 DISALLOW_COPY_AND_ASSIGN(TtsController);
310 }; 331 };
311 332
312 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ 333 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/speech/tts_android.cc ('k') | chrome/browser/speech/tts_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698