23 #include "synth_thread.h" 25 #include <interfaces/SpeechSynthInterface.h> 26 #include <utils/time/wait.h> 28 #include <festival/festival.h> 41 :
Thread(
"FestivalSynthThread",
Thread::OPMODE_WAITFORWAKEUP),
58 __cfg_extra_code =
"";
71 festival_initialize( 1, FESTIVAL_HEAP_SIZE);
72 if (__cfg_voice !=
"") {
73 std::string voice_cmd =
"(voice_" + __cfg_voice +
")";
74 if (! festival_eval_command(voice_cmd.c_str())) {
79 if (__cfg_extra_code !=
"") {
81 if (! festival_eval_command(__cfg_extra_code.c_str())) {
86 say(
"Festival speech synth loaded");
134 festival_text_to_wave(text, wave);
136 float duration = (float)wave.num_samples() / (float)wave.sample_rate();
141 __speechsynth_if->
write();
153 float remaining = duration - (now - &
start);
155 Time waittime(remaining);
160 __speechsynth_if->
write();
void set_duration(const float new_duration)
Set duration value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
unsigned int id() const
Get message ID.
void set_final(const bool new_final)
Set final value.
bool msgq_empty()
Check if queue is empty.
Fawkes library namespace.
void get_systime(struct timeval *tv) const
Returns the system time.
A class for handling time.
virtual void loop()
Code to execute in the thread.
SayMessage Fawkes BlackBoard Interface Message.
virtual void unregister_listener(BlackBoardInterfaceListener *listener)
Unregister BB interface listener.
Thread class encapsulation of pthreads.
void write()
Write from local copy into BlackBoard memory.
Base class for all Fawkes BlackBoard interfaces.
Logger * logger
This is the Logger member used to access the logger.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
Clock * clock
By means of this member access to the clock is given.
void wait_systime()
Wait (sleep) for this system time.
virtual void register_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Register BB event listener.
void msgq_pop()
Erase first message from queue.
void wakeup()
Wake up thread.
Base class for exceptions in Fawkes.
void set_text(const char *new_text)
Set text value.
virtual void init()
Initialize the thread.
Message * msgq_first()
Get the first message from the message queue.
virtual void finalize()
Finalize the thread.
const char * name() const
Get name of thread.
bool msgq_first_is()
Check if first message has desired type.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
FestivalSynthThread()
Constructor.
virtual bool bb_interface_message_received(fawkes::Interface *interface, fawkes::Message *message)
BlackBoard message received notification.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
virtual void once()
Execute an action exactly once.
char * text() const
Get text value.
Configuration * config
This is the Configuration member used to access the configuration.
void bbil_add_message_interface(Interface *interface)
Add an interface to the message received watch list.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for writing.
void say(const char *text)
Say something.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
BlackBoard interface listener.
void start(bool wait=true)
Call this method to start the thread.
SpeechSynthInterface Fawkes BlackBoard Interface.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
virtual void close(Interface *interface)=0
Close interface.