OLD | NEW |
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 virtual void OnVoicesChanged() = 0; | 95 virtual void OnVoicesChanged() = 0; |
96 }; | 96 }; |
97 | 97 |
98 // One speech utterance. | 98 // One speech utterance. |
99 class Utterance { | 99 class Utterance { |
100 public: | 100 public: |
101 // Construct an utterance given a profile and a completion task to call | 101 // Construct an utterance given a profile and a completion task to call |
102 // when the utterance is done speaking. Before speaking this utterance, | 102 // when the utterance is done speaking. Before speaking this utterance, |
103 // its other parameters like text, rate, pitch, etc. should all be set. | 103 // its other parameters like text, rate, pitch, etc. should all be set. |
104 explicit Utterance(Profile* profile); | 104 explicit Utterance(Profile* profile); |
105 virtual ~Utterance(); | 105 ~Utterance(); |
106 | 106 |
107 // Sends an event to the delegate. If the event type is TTS_EVENT_END | 107 // Sends an event to the delegate. If the event type is TTS_EVENT_END |
108 // or TTS_EVENT_ERROR, deletes the utterance. If |char_index| is -1, | 108 // or TTS_EVENT_ERROR, deletes the utterance. If |char_index| is -1, |
109 // uses the last good value. | 109 // uses the last good value. |
110 void OnTtsEvent(TtsEventType event_type, | 110 void OnTtsEvent(TtsEventType event_type, |
111 int char_index, | 111 int char_index, |
112 const std::string& error_message); | 112 const std::string& error_message); |
113 | 113 |
114 // Finish an utterance without sending an event to the delegate. | 114 // Finish an utterance without sending an event to the delegate. |
115 void Finish(); | 115 void Finish(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void set_event_delegate( | 182 void set_event_delegate( |
183 base::WeakPtr<UtteranceEventDelegate> event_delegate) { | 183 base::WeakPtr<UtteranceEventDelegate> event_delegate) { |
184 event_delegate_ = event_delegate; | 184 event_delegate_ = event_delegate; |
185 } | 185 } |
186 | 186 |
187 // Getters and setters for internal state. | 187 // Getters and setters for internal state. |
188 Profile* profile() const { return profile_; } | 188 Profile* profile() const { return profile_; } |
189 int id() const { return id_; } | 189 int id() const { return id_; } |
190 bool finished() const { return finished_; } | 190 bool finished() const { return finished_; } |
191 | 191 |
192 protected: | |
193 void set_finished_for_testing(bool finished) { finished_ = finished; } | |
194 | |
195 private: | 192 private: |
196 // The profile that initiated this utterance. | 193 // The profile that initiated this utterance. |
197 Profile* profile_; | 194 Profile* profile_; |
198 | 195 |
199 // The extension ID of the extension providing TTS for this utterance, or | 196 // The extension ID of the extension providing TTS for this utterance, or |
200 // empty if native TTS is being used. | 197 // empty if native TTS is being used. |
201 std::string extension_id_; | 198 std::string extension_id_; |
202 | 199 |
203 // The unique ID of this utterance, used to associate callback functions | 200 // The unique ID of this utterance, used to associate callback functions |
204 // with utterances. | 201 // with utterances. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // any. | 276 // any. |
280 void OnTtsEvent(int utterance_id, | 277 void OnTtsEvent(int utterance_id, |
281 TtsEventType event_type, | 278 TtsEventType event_type, |
282 int char_index, | 279 int char_index, |
283 const std::string& error_message); | 280 const std::string& error_message); |
284 | 281 |
285 // Return a list of all available voices, including the native voice, | 282 // Return a list of all available voices, including the native voice, |
286 // if supported, and all voices registered by extensions. | 283 // if supported, and all voices registered by extensions. |
287 void GetVoices(Profile* profile, std::vector<VoiceData>* out_voices); | 284 void GetVoices(Profile* profile, std::vector<VoiceData>* out_voices); |
288 | 285 |
| 286 // Called by TtsExtensionLoaderChromeOs::LoadTtsExtension when it |
| 287 // finishes loading the built-in TTS component extension. |
| 288 void RetrySpeakingQueuedUtterances(); |
| 289 |
289 // Called by the extension system or platform implementation when the | 290 // Called by the extension system or platform implementation when the |
290 // list of voices may have changed and should be re-queried. | 291 // list of voices may have changed and should be re-queried. |
291 void VoicesChanged(); | 292 void VoicesChanged(); |
292 | 293 |
293 // Add a delegate that wants to be notified when the set of voices changes. | 294 // Add a delegate that wants to be notified when the set of voices changes. |
294 void AddVoicesChangedDelegate(VoicesChangedDelegate* delegate); | 295 void AddVoicesChangedDelegate(VoicesChangedDelegate* delegate); |
295 | 296 |
296 // Remove delegate that wants to be notified when the set of voices changes. | 297 // Remove delegate that wants to be notified when the set of voices changes. |
297 void RemoveVoicesChangedDelegate(VoicesChangedDelegate* delegate); | 298 void RemoveVoicesChangedDelegate(VoicesChangedDelegate* delegate); |
298 | 299 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 std::set<VoicesChangedDelegate*> voices_changed_delegates_; | 343 std::set<VoicesChangedDelegate*> voices_changed_delegates_; |
343 | 344 |
344 // A pointer to the platform implementation of text-to-speech, for | 345 // A pointer to the platform implementation of text-to-speech, for |
345 // dependency injection. | 346 // dependency injection. |
346 TtsPlatformImpl* platform_impl_; | 347 TtsPlatformImpl* platform_impl_; |
347 | 348 |
348 DISALLOW_COPY_AND_ASSIGN(TtsController); | 349 DISALLOW_COPY_AND_ASSIGN(TtsController); |
349 }; | 350 }; |
350 | 351 |
351 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ | 352 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ |
OLD | NEW |