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.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
virtual void loop()
Code to execute in the thread.
virtual void unregister_listener(BlackBoardInterfaceListener *listener)
Unregister BB interface listener.
BlackBoard interface listener.
char * text() const
Get text value.
const char * name() const
Get name of thread.
Clock * clock
By means of this member access to the clock is given.
FestivalSynthThread()
Constructor.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
virtual void finalize()
Finalize the thread.
Logger * logger
This is the Logger member used to access the logger.
virtual void close(Interface *interface)=0
Close interface.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
Fawkes library namespace.
virtual void init()
Initialize the thread.
SpeechSynthInterface Fawkes BlackBoard Interface.
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.
Base class for all Fawkes BlackBoard interfaces.
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.
Configuration * config
This is the Configuration member used to access the configuration.
void say(const char *text)
Say something.
SayMessage Fawkes BlackBoard Interface Message.
void set_text(const char *new_text)
Set text value.
A class for handling time.
virtual void once()
Execute an action exactly once.
Thread class encapsulation of pthreads.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
void start(bool wait=true)
Call this method to start the thread.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
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
Log debug message.
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
Open interface for writing.
Base class for exceptions in Fawkes.