Fawkes API
Fawkes Development Version
|
23 #include "synth_thread.h"
25 #include <festival/festival.h>
26 #include <interfaces/SpeechSynthInterface.h>
27 #include <utils/time/wait.h>
39 :
Thread(
"FestivalSynthThread",
Thread::OPMODE_WAITFORWAKEUP),
67 festival_initialize( 1, FESTIVAL_HEAP_SIZE);
68 if (cfg_voice_ !=
"") {
69 std::string voice_cmd =
"(voice_" + cfg_voice_ +
")";
70 if (!festival_eval_command(voice_cmd.c_str())) {
75 if (cfg_extra_code_ !=
"") {
77 if (!festival_eval_command(cfg_extra_code_.c_str())) {
82 say(
"Festival speech synth loaded");
128 festival_text_to_wave(text, wave);
130 float duration = (float)wave.num_samples() / (float)wave.sample_rate();
135 speechsynth_if_->
write();
147 float remaining = duration - (now - &
start);
149 Time waittime(remaining);
154 speechsynth_if_->
write();
bool msgq_first_is()
Check if first message has desired type.
void msgq_pop()
Erase first message from queue.
bool msgq_empty()
Check if queue is empty.
virtual void register_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Register BB event listener.
void set_final(const bool new_final)
Set final value.
virtual void loop()
Code to execute in the thread.
virtual void unregister_listener(BlackBoardInterfaceListener *listener)
Unregister BB interface listener.
char * text() const
Get text value.
const char * name() const
FestivalSynthThread()
Constructor.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
virtual void finalize()
Finalize the thread.
virtual void close(Interface *interface)=0
virtual void log_error(const char *component, const char *format,...)=0
virtual void init()
Initialize the thread.
void wait_systime()
Wait (sleep) for this system time.
void bbil_add_message_interface(Interface *interface)
Add an interface to the message received watch list.
virtual bool bb_interface_message_received(fawkes::Interface *interface, fawkes::Message *message)
BlackBoard message received notification.
void get_systime(struct timeval *tv) const
Returns the system time.
void say(const char *text)
Say something.
void set_text(const char *new_text)
Set text value.
virtual void once()
Execute an action exactly once.
void start(bool wait=true)
Call this method to start the thread.
virtual std::string get_string(const char *path)=0
unsigned int id() const
Get message ID.
void set_duration(const float new_duration)
Set duration value.
Message * msgq_first()
Get the first message from the message queue.
virtual void log_debug(const char *component, const char *format,...)=0
void write()
Write from local copy into BlackBoard memory.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0