| // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef SPEECH_SYNTHESIS_SPEECH_SYNTHESIZER_SERVICE_H_ |
| #define SPEECH_SYNTHESIS_SPEECH_SYNTHESIZER_SERVICE_H_ |
| |
| #include <chromeos/dbus/abstract_dbus_service.h> |
| #include <chromeos/dbus/dbus.h> |
| #include <chromeos/dbus/service_constants.h> |
| |
| #include "pico/pico_tts_engine.h" |
| #include "threading.h" |
| #include "tts_engine.h" |
| #include "tts_service.h" |
| |
| namespace speech_synthesis { |
| namespace gobject { |
| struct SpeechSynthesizer; |
| } // namespace gobject |
| |
| // Provides a wrapper for exporting SpeechSynthesizerInterface to |
| // D-Bus and entering the glib run loop. |
| // |
| // ::g_type_init() must be called before this class is used. |
| class SpeechSynthesizerService : public chromeos::dbus::AbstractDbusService { |
| public: |
| explicit SpeechSynthesizerService(); |
| virtual ~SpeechSynthesizerService(); |
| |
| //////////////////////////////////////////////////////////////////////////// |
| // Implementing chromeos::dbus::AbstractDbusService |
| virtual bool Initialize(); |
| virtual bool Reset(); |
| |
| virtual bool Run(); |
| |
| virtual const char* service_name() const { |
| return kSpeechSynthesizerServiceName; |
| } |
| virtual const char* service_path() const { |
| return kSpeechSynthesizerServicePath; |
| } |
| virtual const char* service_interface() const { |
| return kSpeechSynthesizerInterface; |
| } |
| virtual GObject* service_object() const { |
| return G_OBJECT(speech_synthesizer_.get()); |
| } |
| |
| // Interface function prototypes which wrap service. |
| gboolean Speak(gchar *text, |
| GError **error); |
| gboolean SetProperties(gchar *properties, |
| GError **error); |
| gboolean Stop(GError **error); |
| gboolean IsSpeaking(gboolean *OUT_isSpeaking_requested, |
| GError **error); |
| |
| protected: |
| virtual GMainLoop* main_loop() { return main_loop_; } |
| |
| private: |
| TtsService *ttsService; |
| TtsEngine *engine; |
| AudioOutput *audio_output; |
| UtteranceOptions *utterance_options; |
| |
| scoped_ptr<gobject::SpeechSynthesizer> speech_synthesizer_; |
| GMainLoop* main_loop_; |
| |
| gboolean AddProperties(gchar *properties); |
| }; |
| |
| } // namespace speech_synthesis |
| #endif // SPEECH_SYNTHESIS_SPEECH_SYNTHESIZER_SERVICE_H_ |
| |
| |