talking_watch_sample.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <sstream>
00003 #include <boost/regex.hpp>
00004 #include <boost/date_time/posix_time/posix_time.hpp>
00005 #include <ros/ros.h>
00006 #include "rospeex_if/rospeex.h"
00007 
00008 static rospeex::Interface interface;
00009 
00010 void sr_response( const std::string& msg )
00011 {
00012         using boost::posix_time::ptime;
00013         using boost::posix_time::second_clock;
00014 
00015         std::cerr << "you said : " << msg << std::endl;
00016         boost::regex time_reg(".*何時.*");
00017         std::string text = "";
00018         if ( boost::regex_match(msg, time_reg) ) {
00019                 ptime now = second_clock::local_time();
00020                 std::stringstream ss;
00021                 ss << now.time_of_day().hours() << "時" << now.time_of_day().minutes() << "分です";
00022                 text = ss.str();
00023                 std::cerr << "robot reply : " << text << std::endl;
00024                 interface.say( text, "ja", "nict" );
00025         }
00026 }
00027 
00028 int main( int argc, char** argv )
00029 {
00030         ros::init(argc, argv, "sr_ss_demo");
00031 
00032         interface.init();
00033         interface.registerSRResponse( sr_response );
00034         interface.setSPIConfig("ja", "nict");
00035         ros::spin();
00036         return 0;
00037 }


rospeex_samples
Author(s): Komei Sugiura
autogenerated on Thu Apr 20 2017 03:09:00