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

Unified Diff: chrome/browser/speech/tts_controller.h

Issue 12589005: Implement web speech synthesis. (Closed) Base URL: http://git.chromium.org/chromium/src.git@webtts
Patch Set: Fix android build Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/speech/extension_api/tts_extension_api.cc ('k') | chrome/browser/speech/tts_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/speech/tts_controller.h
diff --git a/chrome/browser/speech/tts_controller.h b/chrome/browser/speech/tts_controller.h
index a479a96c69ae4de7b47aa14d20472812c358a247..10044bbac82ee5e95ffb15202b13afc1b5b9872b 100644
--- a/chrome/browser/speech/tts_controller.h
+++ b/chrome/browser/speech/tts_controller.h
@@ -8,16 +8,17 @@
#include <queue>
#include <set>
#include <string>
+#include <vector>
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "googleurl/src/gurl.h"
+class Utterance;
class TtsPlatformImpl;
class Profile;
namespace base {
-class ListValue;
class Value;
}
@@ -33,6 +34,9 @@ enum TtsEventType {
TTS_EVENT_ERROR
};
+// Returns true if this event type is one that indicates an utterance
+// is finished and can be destroyed.
+bool IsFinalTtsEventType(TtsEventType event_type);
// The continuous parameters that apply to a given utterance.
struct UtteranceContinuousParameters {
@@ -43,6 +47,27 @@ struct UtteranceContinuousParameters {
double volume;
};
+// Information about one voice.
+struct VoiceData {
+ VoiceData();
+ ~VoiceData();
+
+ std::string name;
+ std::string lang;
+ std::string gender;
+ std::string extension_id;
+ std::vector<std::string> events;
+};
+
+// Class that wants to receive events on utterances.
+class UtteranceEventDelegate {
+ public:
+ virtual ~UtteranceEventDelegate() {}
+ virtual void OnTtsEvent(Utterance* utterance,
+ TtsEventType event_type,
+ int char_index,
+ const std::string& error_message) = 0;
+};
// One speech utterance.
class Utterance {
@@ -125,6 +150,11 @@ class Utterance {
extension_id_ = extension_id;
}
+ UtteranceEventDelegate* event_delegate() const { return event_delegate_; }
+ void set_event_delegate(UtteranceEventDelegate* event_delegate) {
+ event_delegate_ = event_delegate;
+ }
+
// Getters and setters for internal state.
Profile* profile() const { return profile_; }
int id() const { return id_; }
@@ -164,6 +194,11 @@ class Utterance {
// The URL of the page where the source extension called speak.
GURL src_url_;
+ // The delegate to be called when an utterance event is fired.
+ // Weak reference; it will be cleared after we fire a "final" event
+ // (as determined by IsFinalTtsEventType).
+ UtteranceEventDelegate* event_delegate_;
+
// The parsed options.
std::string voice_name_;
std::string lang_;
@@ -180,7 +215,6 @@ class Utterance {
bool finished_;
};
-
// Singleton class that manages text-to-speech for the TTS and TTS engine
// extension APIs, maintaining a queue of pending utterances and keeping
// track of all state.
@@ -212,7 +246,7 @@ class TtsController {
// Return a list of all available voices, including the native voice,
// if supported, and all voices registered by extensions.
- base::ListValue* GetVoices(Profile* profile);
+ void GetVoices(Profile* profile, std::vector<VoiceData>* out_voices);
// Called by TtsExtensionLoaderChromeOs::LoadTtsExtension when it
// finishes loading the built-in TTS component extension.
« no previous file with comments | « chrome/browser/speech/extension_api/tts_extension_api.cc ('k') | chrome/browser/speech/tts_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698