Fawkes API
Fawkes Development Version
|
23 #include "speechsynth_thread.h"
25 #include <alcore/alerror.h>
26 #include <alproxies/allauncherproxy.h>
27 #include <alproxies/altexttospeechproxy.h>
28 #include <interfaces/SpeechSynthInterface.h>
42 :
Thread(
"NaoQiSpeechSynthThread",
Thread::OPMODE_WAITFORWAKEUP),
59 AL::ALPtr<AL::ALLauncherProxy> launcher(
new AL::ALLauncherProxy(
naoqi_broker));
60 bool is_tts_available = launcher->isModulePresent(
"ALTextToSpeech");
62 if (!is_tts_available) {
63 throw Exception(
"NaoQi ALTextToSpeech is not available");
65 }
catch (AL::ALError &e) {
66 throw Exception(
"Checking ALTextToSpeech aliveness failed: %s", e.toString().c_str());
69 altts_ = AL::ALPtr<AL::ALTextToSpeechProxy>(
new AL::ALTextToSpeechProxy(
naoqi_broker));
80 speechsynth_if_ = NULL;
87 NaoQiSpeechSynthThread::stop_speech()
89 if (tts_task_id_ != -1) {
90 if (altts_->isRunning(tts_task_id_)) {
91 altts_->stop(tts_task_id_);
98 NaoQiSpeechSynthThread::say(
const char *text)
100 tts_task_id_ = altts_->say(text);
106 bool working = (tts_task_id_ != -1) && altts_->isRunning(tts_task_id_);
111 speechsynth_if_->
write();
116 NaoQiSpeechSynthThread::process_messages()
void msgq_pop()
Erase first message from queue.
bool msgq_empty()
Check if queue is empty.
void set_final(const bool new_final)
Set final value.
MessageType * msgq_first_safe(MessageType *&msg)
Get first message casted to the desired type without exceptions.
virtual ~NaoQiSpeechSynthThread()
Destructor.
Thread aspect to use blocked timing.
virtual void loop()
Code to execute in the thread.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
virtual void close(Interface *interface)=0
Close interface.
AL::ALPtr< AL::ALBroker > naoqi_broker
NaoQi broker.
Fawkes library namespace.
NaoQiSpeechSynthThread()
Constructor.
SpeechSynthInterface Fawkes BlackBoard Interface.
SayMessage Fawkes BlackBoard Interface Message.
virtual void finalize()
Finalize the thread.
Thread class encapsulation of pthreads.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
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.
virtual void init()
Initialize the thread.
Base class for exceptions in Fawkes.