1 // speech synthesis interface subsystem
3 // Written by Torsten Dreyer, started April 2014
5 // Copyright (C) 2014 Torsten Dreyer - torsten (at) t3r (dot) de
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include "flitevoice.hxx"
27 #include <Main/fg_props.hxx>
28 #include <simgear/sound/sample_group.hxx>
29 #include <flite_hts_engine.h>
33 #include "VoiceSynthesizer.hxx"
35 FGFLITEVoice::FGFLITEVoice(FGVoiceMgr * mgr, const SGPropertyNode_ptr node)
36 : FGVoice(mgr), _synthesizer( NULL )
38 string voice = globals->get_fg_root() + "/ATC/cmu_us_arctic_slt.htsvoice";
39 _synthesizer = new FLITEVoiceSynthesizer( voice.c_str() );
41 SGSoundMgr *smgr = globals->get_soundmgr();
42 _sgr = smgr->find("atc", true);
43 _sgr->tie_to_listener();
45 node->getNode("text", true)->addChangeListener(this);
47 SG_LOG(SG_ALL, SG_ALERT, "FLITEVoice initialized");
50 FGFLITEVoice::~FGFLITEVoice()
53 SG_LOG(SG_ALL, SG_ALERT, "FLITEVoice dtor()");
56 void FGFLITEVoice::speak(const string & msg)
58 SG_LOG(SG_ALL, SG_ALERT, "FLITEVoice speak(" << msg << ")");
60 _sgr->remove("flite");
62 string s = simgear::strutils::strip( msg );
63 if( false == s.empty() ) {
64 SGSoundSample * sample = _synthesizer->synthesize( msg, 1.0, 0.5, 0.5 );
65 _sgr->add(sample, "flite");
66 _sgr->set_volume(1.0);
68 _sgr->play("flite", true);
72 void FGFLITEVoice::update()