00001 /******************************************************************************* 00002 * TalkingHead - A talking head for robots 00003 * Copyright (C) 2012 AG Aktives Sehen <agas@uni-koblenz.de> 00004 * Universitaet Koblenz-Landau 00005 * 00006 * This program is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00019 * MA 02110-1301 USA or see <http://www.gnu.org/licenses/>. 00020 *******************************************************************************/ 00021 00022 #ifndef TALKING_HEAD_INCLUDE_FESTIVALGENERATOR_H_ 00023 #define TALKING_HEAD_INCLUDE_FESTIVALGENERATOR_H_ 00024 00025 #include <festival.h> 00026 00027 #include <QObject> 00028 #include <QTimer> 00029 00030 #include <ros/callback_queue.h> 00031 #include <ros/ros.h> 00032 #include <std_msgs/Empty.h> 00033 #include <std_msgs/String.h> 00034 00035 #include <fstream> 00036 #include <ostream> 00037 #include <string> 00038 #include <vector> 00039 00046 class FestivalGenerator: public QObject 00047 { 00048 Q_OBJECT 00049 00050 public: 00052 explicit FestivalGenerator( QObject *parent = 0 ); 00053 00055 ~FestivalGenerator(); 00056 00057 void callbackSynth( const std_msgs::String::ConstPtr& msg ); 00058 void callbackTalkingFinished( const std_msgs::String::ConstPtr& msg ); 00059 00061 void subscribeWithNodeHandle( ros::NodeHandle node_handle ); 00062 00063 public slots: 00064 void run(); 00065 00066 private: 00067 bool synth_phonemes_; 00068 bool synth_words_; 00069 bool publish_smiley_; 00070 std::string text_for_synth_; 00071 00072 std::vector<std::string> punctuation_characters_; 00073 std::vector<std::string> smileys_; 00074 00075 QTimer* timer_; 00076 00078 ros::Publisher phonemes_publisher_; 00079 ros::Subscriber subscriber_; 00080 ros::Subscriber talking_finished_subscriber_; 00081 00082 00084 void synthPhonemes( std::string text ); 00085 00087 void synthWords( std::string text ); 00088 00090 std::string trimSpaces( std::string text ); 00091 00093 std::string prepareText( std::string text ); 00094 00096 std::string clearSmileys( std::string text ); 00097 00098 }; 00099 00100 #endif // TALKING_HEAD_INCLUDE_FESTIVALGENERATOR_H_