Fawkes API  Fawkes Development Version
synth_thread.h
1 
2 /***************************************************************************
3  * synth_thread.h - Flite synthesis thread
4  *
5  * Created: Tue Oct 28 14:31:58 2008
6  * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _PLUGINS_FLITE_SYNTH_THREAD_H_
24 #define _PLUGINS_FLITE_SYNTH_THREAD_H_
25 
26 #include <aspect/blackboard.h>
27 #include <aspect/blocked_timing.h>
28 #include <aspect/clock.h>
29 #include <aspect/configurable.h>
30 #include <aspect/logging.h>
31 #include <blackboard/interface_listener.h>
32 #include <core/threading/thread.h>
33 #include <flite/flite.h>
34 
35 #include <string>
36 
37 namespace fawkes {
38 class SpeechSynthInterface;
39 }
40 
42  public fawkes::LoggingAspect,
44  public fawkes::ClockAspect,
47 {
48 public:
50 
51  virtual void init();
52  virtual void finalize();
53  virtual void loop();
54 
55  void say(const char *text);
56 
57  virtual bool bb_interface_message_received(fawkes::Interface *interface,
58  fawkes::Message * message) throw();
59 
60  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
61 protected:
62  virtual void
63  run()
64  {
65  Thread::run();
66  }
67 
68 private: /* methods */
69  void play_wave(cst_wave *wave);
70  float get_duration(cst_wave *wave);
71 
72 private:
73  fawkes::SpeechSynthInterface *speechsynth_if_;
74 
75  std::string cfg_soundcard_;
76 
77  cst_voice *voice_;
78 };
79 
80 #endif
fawkes::Message
Definition: message.h:41
FliteSynthThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: synth_thread.h:63
fawkes::BlackBoardInterfaceListener
Definition: interface_listener.h:47
FliteSynthThread::finalize
virtual void finalize()
Finalize the thread.
Definition: synth_thread.cpp:66
FliteSynthThread::init
virtual void init()
Initialize the thread.
Definition: synth_thread.cpp:52
fawkes::BlackBoardAspect
Definition: blackboard.h:38
fawkes
fawkes::LoggingAspect
Definition: logging.h:38
FliteSynthThread::bb_interface_message_received
virtual bool bb_interface_message_received(fawkes::Interface *interface, fawkes::Message *message)
BlackBoard message received notification.
Definition: synth_thread.cpp:96
fawkes::SpeechSynthInterface
Definition: SpeechSynthInterface.h:39
FliteSynthThread::say
void say(const char *text)
Say something.
Definition: synth_thread.cpp:106
fawkes::Interface
Definition: interface.h:78
FliteSynthThread
Definition: synth_thread.h:41
FliteSynthThread::FliteSynthThread
FliteSynthThread()
Constructor.
Definition: synth_thread.cpp:45
fawkes::Thread
Definition: thread.h:45
FliteSynthThread::loop
virtual void loop()
Code to execute in the thread.
Definition: synth_thread.cpp:74
fawkes::ConfigurableAspect
Definition: configurable.h:38
fawkes::ClockAspect
Definition: clock.h:40