-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from k-okada/add_speech
[WIP] add subscribers/speech.cpp
- Loading branch information
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2015 Aldebaran | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
/* | ||
* LOCAL includes | ||
*/ | ||
#include "speech.hpp" | ||
|
||
|
||
namespace naoqi | ||
{ | ||
namespace subscriber | ||
{ | ||
|
||
SpeechSubscriber::SpeechSubscriber( const std::string& name, const std::string& speech_topic, const qi::SessionPtr& session ): | ||
speech_topic_(speech_topic), | ||
BaseSubscriber( name, speech_topic, session ), | ||
p_tts_( session->service("ALTextToSpeech") ) | ||
{} | ||
|
||
void SpeechSubscriber::reset( ros::NodeHandle& nh ) | ||
{ | ||
sub_speech_ = nh.subscribe( speech_topic_, 10, &SpeechSubscriber::speech_callback, this ); | ||
|
||
is_initialized_ = true; | ||
} | ||
|
||
void SpeechSubscriber::speech_callback( const std_msgs::StringConstPtr& string_msg ) | ||
{ | ||
p_tts_.async<void>("say", string_msg->data); | ||
} | ||
|
||
} //publisher | ||
} // naoqi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2015 Aldebaran | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
|
||
#ifndef SPEECH_SUBSCRIBER_HPP | ||
#define SPEECH_SUBSCRIBER_HPP | ||
|
||
/* | ||
* LOCAL includes | ||
*/ | ||
#include "subscriber_base.hpp" | ||
|
||
/* | ||
* ROS includes | ||
*/ | ||
#include <ros/ros.h> | ||
#include <std_msgs/String.h> | ||
|
||
namespace naoqi | ||
{ | ||
namespace subscriber | ||
{ | ||
|
||
class SpeechSubscriber: public BaseSubscriber<SpeechSubscriber> | ||
{ | ||
public: | ||
SpeechSubscriber( const std::string& name, const std::string& speech_topic, const qi::SessionPtr& session ); | ||
~SpeechSubscriber(){} | ||
|
||
void reset( ros::NodeHandle& nh ); | ||
void speech_callback( const std_msgs::StringConstPtr& speech_msg ); | ||
|
||
private: | ||
|
||
std::string speech_topic_; | ||
|
||
qi::AnyObject p_tts_; | ||
ros::Subscriber sub_speech_; | ||
|
||
|
||
|
||
}; // class Speech | ||
|
||
} // subscriber | ||
}// naoqi | ||
#endif |