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();
virtual bool bb_interface_message_received(fawkes::Interface *interface, fawkes::Message *message) noexcept
BlackBoard message received notification.
virtual void loop()
Code to execute in the thread.
virtual void once()
Execute an action exactly once.
void say(const char *text)
Say something.
FestivalSynthThread()
Constructor.
virtual void init()
Initialize the thread.
virtual void finalize()
Finalize the thread.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
BlackBoard interface listener.
void bbil_add_message_interface(Interface *interface)
Add an interface to the message received watch list.
virtual void unregister_listener(BlackBoardInterfaceListener *listener)
Unregister BB interface listener.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for writing.
virtual void register_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Register BB event listener.
virtual void close(Interface *interface)=0
Close interface.
Clock * clock
By means of this member access to the clock is given.
void get_systime(struct timeval *tv) const
Returns the system time.
Configuration * config
This is the Configuration member used to access the configuration.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
Base class for exceptions in Fawkes.
Base class for all Fawkes BlackBoard interfaces.
bool msgq_first_is()
Check if first message has desired type.
void msgq_pop()
Erase first message from queue.
Message * msgq_first()
Get the first message from the message queue.
void write()
Write from local copy into BlackBoard memory.
bool msgq_empty()
Check if queue is empty.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
Logger * logger
This is the Logger member used to access the logger.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
unsigned int id() const
Get message ID.
SayMessage Fawkes BlackBoard Interface Message.
char * text() const
Get text value.
SpeechSynthInterface Fawkes BlackBoard Interface.
void set_duration(const float new_duration)
Set duration value.
void set_text(const char *new_text)
Set text value.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
void set_final(const bool new_final)
Set final value.
Thread class encapsulation of pthreads.
const char * name() const
Get name of thread.
void start(bool wait=true)
Call this method to start the thread.
A class for handling time.
void wait_systime()
Wait (sleep) for this system time.
Fawkes library namespace.