23 #include "speechsynth_thread.h" 25 #include <alcore/alerror.h> 26 #include <alproxies/allauncherproxy.h> 27 #include <alproxies/altexttospeechproxy.h> 29 #include <interfaces/SpeechSynthInterface.h> 43 :
Thread(
"NaoQiSpeechSynthThread",
Thread::OPMODE_WAITFORWAKEUP),
62 AL::ALPtr<AL::ALLauncherProxy> launcher(
new AL::ALLauncherProxy(
naoqi_broker));
63 bool is_tts_available = launcher->isModulePresent(
"ALTextToSpeech");
65 if (! is_tts_available) {
66 throw Exception(
"NaoQi ALTextToSpeech is not available");
68 }
catch (AL::ALError& e) {
69 throw Exception(
"Checking ALTextToSpeech aliveness failed: %s",
70 e.toString().c_str());
74 AL::ALPtr<AL::ALTextToSpeechProxy>(
new AL::ALTextToSpeechProxy(
naoqi_broker));
87 __speechsynth_if = NULL;
95 NaoQiSpeechSynthThread::stop_speech()
97 if (__tts_task_id != -1) {
98 if (__altts->isRunning(__tts_task_id)) {
99 __altts->stop(__tts_task_id);
106 NaoQiSpeechSynthThread::say(
const char *text)
108 __tts_task_id = __altts->say(text);
114 bool working = (__tts_task_id != -1) && __altts->isRunning(__tts_task_id);
118 __speechsynth_if->
set_final( ! working );
119 __speechsynth_if->
write();
125 NaoQiSpeechSynthThread::process_messages()
virtual void loop()
Code to execute in the thread.
virtual void finalize()
Finalize the thread.
void set_final(const bool new_final)
Set final value.
bool msgq_empty()
Check if queue is empty.
Fawkes library namespace.
AL::ALPtr< AL::ALBroker > naoqi_broker
NaoQi broker.
virtual void init()
Initialize the thread.
NaoQiSpeechSynthThread()
Constructor.
SayMessage Fawkes BlackBoard Interface Message.
Thread class encapsulation of pthreads.
void write()
Write from local copy into BlackBoard memory.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
Thread aspect to use blocked timing.
void msgq_pop()
Erase first message from queue.
Base class for exceptions in Fawkes.
virtual ~NaoQiSpeechSynthThread()
Destructor.
MessageType * msgq_first_safe(MessageType *&msg)
Get first message casted to the desired type without exceptions.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for writing.
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.