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_FESTIVALSYNTHESIZER_H_ 00023 #define TALKING_HEAD_INCLUDE_FESTIVALSYNTHESIZER_H_ 00024 00025 #include <festival.h> 00026 00027 #include <ros/callback_queue.h> 00028 #include <ros/ros.h> 00029 #include <std_msgs/Empty.h> 00030 #include <std_msgs/String.h> 00031 00032 #include <fstream> 00033 #include <ostream> 00034 #include <string> 00035 #include <vector> 00036 00037 class pa_simple; 00038 00045 class FestivalSynthesizer 00046 { 00047 public: 00048 00050 FestivalSynthesizer(); 00051 00053 ~FestivalSynthesizer(); 00054 00055 void callbackSynth( const std_msgs::String::ConstPtr& msg ); 00056 00057 void run(); 00058 00059 private: 00060 00061 pa_simple* pa_simple_; 00062 00063 bool festival_initialized_; 00064 bool synth_speech_; 00065 std::string text_for_synth_; 00066 std::vector<std::string> punctuation_characters_; 00067 std::vector<std::string> smileys_; 00068 00070 ros::Publisher talking_finished_publisher_; 00071 ros::Subscriber subscriber_; 00072 00073 void initFestival(); 00074 00076 void synthSpeech ( std::string text ); 00077 00079 std::string trimSpaces( std::string text ); 00080 00082 std::string prepareText( std::string text ); 00083 00085 std::string clearSmileys( std::string text ); 00086 }; 00087 00088 #endif // TALKING_HEAD_INCLUDE_FESTIVALSYNTHESIZER_H_