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>
31 using namespace fawkes;
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()