2 * VoiceSynthesizer.hxx - wraps flite+hts_engine
3 * Copyright (C) 2014 Torsten Dreyer - torsten (at) t3r (dot) de
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef VOICESYNTHESIZER_HXX_
20 #define VOICESYNTHESIZER_HXX_
22 #include <simgear/sound/sample_openal.hxx>
23 #include <simgear/threads/SGQueue.hxx>
26 struct _Flite_HTS_Engine;
29 * A Voice Synthesizer Interface
31 class VoiceSynthesizer {
33 virtual ~VoiceSynthesizer() {};
34 virtual SGSoundSample * synthesize( const std::string & text, double volume, double speed, double pitch ) = 0;
37 class SoundSampleReadyListener {
39 virtual ~SoundSampleReadyListener() {}
40 virtual void SoundSampleReady( SGSharedPtr<SGSoundSample> ) = 0;
43 struct SynthesizeRequest {
50 SynthesizeRequest( const SynthesizeRequest & other ) {
53 volume = other.volume;
55 listener = other.listener;
58 SynthesizeRequest & operator = ( const SynthesizeRequest & other ) {
61 volume = other.volume;
63 listener = other.listener;
71 SoundSampleReadyListener * listener;
75 * A Voice Synthesizer using FLITE+HTS
77 class FLITEVoiceSynthesizer : public VoiceSynthesizer {
81 CMU_US_ARCTIC_SLT = 0,
84 VOICE_UNKNOWN // keep this at the end
87 static std::string getVoicePath( voice_t voice );
88 static std::string getVoicePath( const std::string & voice );
90 FLITEVoiceSynthesizer( const std::string & voice );
91 ~FLITEVoiceSynthesizer();
92 virtual SGSoundSample * synthesize( const std::string & text, double volume, double speed, double pitch );
94 virtual void synthesize( SynthesizeRequest & request );
96 struct _Flite_HTS_Engine * _engine;
99 WorkerThread * _worker;
101 typedef SGBlockingQueue<SynthesizeRequest> SynthesizeRequestList;
102 SynthesizeRequestList _requests;
107 #endif /* VOICESYNTHESIZER_HXX_ */