diff --git a/source/RobotAPI/components/units/SpeechObserver.cpp b/source/RobotAPI/components/units/SpeechObserver.cpp index dec46e56aa59676076607cf8fa7a280b9742737c..15b2766b4f07989833590f8a3e2a0aa3bbdd134a 100644 --- a/source/RobotAPI/components/units/SpeechObserver.cpp +++ b/source/RobotAPI/components/units/SpeechObserver.cpp @@ -1,6 +1,6 @@ /* * This file is part of ArmarX. - * + * * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), * Karlsruhe Institute of Technology (KIT), all rights reserved. * @@ -23,8 +23,6 @@ #include "SpeechObserver.h" -#include <ArmarXCore/util/json/JSONObject.h> - using namespace armarx; SpeechObserver::SpeechObserver() @@ -35,9 +33,6 @@ void SpeechObserver::onInitObserver() { usingTopic(getProperty<std::string>("TextToSpeechTopicName").getValue()); usingTopic(getProperty<std::string>("TextToSpeechStateTopicName").getValue()); - auto proxy = getObjectAdapter()->addWithUUID(new SpeechListenerImpl(this)); - getIceManager()->subscribeTopic(proxy, "Speech_Commands"); - } void SpeechObserver::onConnectObserver() @@ -47,16 +42,12 @@ void SpeechObserver::onConnectObserver() offerDataFieldWithDefault("TextToSpeech", "TextChangeCounter", Variant(reportTextCounter), "Counter for text updates"); offerDataFieldWithDefault("TextToSpeech", "State", Variant(""), "Current TTS state"); - offerDataFieldWithDefault("TextToSpeech", "StateChangeCounter", Variant(reportStateCounter), "Counter for state updates"); - - offerChannel("SpeechToText", "SpeechToText channel"); - offerDataFieldWithDefault("TextToSpeech", "RecognizedText", Variant(std::string()), "Text recognized by the SpeechRecogntion"); - + offerDataFieldWithDefault("TextToSpeech", "StateChangeCounter", Variant(reportStateCounter), "Counter for text updates"); } std::string SpeechObserver::SpeechStateToString(TextToSpeechStateType state) { - switch (state) + switch(state) { case eIdle: return "Idle"; @@ -79,7 +70,7 @@ void SpeechObserver::reportState(TextToSpeechStateType state, const Ice::Current updateChannel("TextToSpeech"); } -void SpeechObserver::reportText(const std::string& text, const Ice::Current& c) +void SpeechObserver::reportText(const std::string& text, const Ice::Current&) { ScopedLock lock(dataMutex); reportTextCounter++; @@ -93,24 +84,3 @@ void SpeechObserver::reportTextWithParams(const std::string& text, const Ice::St ScopedLock lock(dataMutex); ARMARX_WARNING << "reportTextWithParams is not implemented"; } - -SpeechListenerImpl::SpeechListenerImpl(SpeechObserver* obs) : - obs(obs) -{ - -} - - -void armarx::SpeechListenerImpl::reportText(const std::string& text, const Ice::Current&) -{ - ScopedLock lock(dataMutex); - JSONObject json; - json.fromString(text); - obs->setDataField("SpeechToText", "RecognizedText", Variant(json.getString("text"))); -} - -void armarx::SpeechListenerImpl::reportTextWithParams(const std::string&, const Ice::StringSeq&, const Ice::Current&) -{ - ScopedLock lock(dataMutex); - ARMARX_WARNING << deactivateSpam(100) << "reportTextWithParams is not implemented"; -} diff --git a/source/RobotAPI/components/units/SpeechObserver.h b/source/RobotAPI/components/units/SpeechObserver.h index 4378e568ac6ba3e468aded4852b24092e2f25474..ef6e6580d23f0ec7a04f93daa2bddc38a7342565 100644 --- a/source/RobotAPI/components/units/SpeechObserver.h +++ b/source/RobotAPI/components/units/SpeechObserver.h @@ -1,6 +1,6 @@ /* * This file is part of ArmarX. - * + * * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), * Karlsruhe Institute of Technology (KIT), all rights reserved. * @@ -39,25 +39,11 @@ namespace armarx defineOptionalProperty<std::string>("TextToSpeechStateTopicName", "TextToSpeechState", "Name of the TextToSpeechStateTopic"); } }; - class SpeechObserver; - class SpeechListenerImpl : public TextListenerInterface - { - public: - SpeechListenerImpl(SpeechObserver* obs); - protected: - SpeechObserver* obs; - Mutex dataMutex; - // TextListenerInterface interface - public: - void reportText(const std::string&, const Ice::Current&) override; - void reportTextWithParams(const std::string&, const Ice::StringSeq&, const Ice::Current&) override; - }; class SpeechObserver : - virtual public Observer, - virtual public SpeechObserverInterface + virtual public Observer, + virtual public SpeechObserverInterface { - friend class SpeechListenerImpl; public: SpeechObserver();