4 * Created on: Apr 24, 2014
8 #ifndef VOICESYNTHESIZER_HXX_
9 #define VOICESYNTHESIZER_HXX_
11 #include <simgear/sound/sample_openal.hxx>
12 #include <simgear/threads/SGQueue.hxx>
15 struct _Flite_HTS_Engine;
18 * A Voice Synthesizer Interface
20 class VoiceSynthesizer {
22 virtual ~VoiceSynthesizer() {};
23 virtual SGSoundSample * synthesize( const std::string & text ) = 0;
26 class SoundSampleReadyListener {
28 virtual ~SoundSampleReadyListener() {}
29 virtual void SoundSampleReady( SGSharedPtr<SGSoundSample> ) = 0;
32 struct SynthesizeRequest {
34 speed = volume = pitch = 1.0;
37 SynthesizeRequest( const SynthesizeRequest & other ) {
40 volume = other.volume;
42 listener = other.listener;
45 SynthesizeRequest & operator = ( const SynthesizeRequest & other ) {
48 volume = other.volume;
50 listener = other.listener;
58 SoundSampleReadyListener * listener;
62 * A Voice Synthesizer using FLITE+HTS
64 class FLITEVoiceSynthesizer : public VoiceSynthesizer {
66 FLITEVoiceSynthesizer( const std::string & voice );
67 ~FLITEVoiceSynthesizer();
68 virtual SGSoundSample * synthesize( const std::string & text );
70 virtual void synthesize( SynthesizeRequest & request );
72 struct _Flite_HTS_Engine * _engine;
75 WorkerThread * _worker;
77 typedef SGBlockingQueue<SynthesizeRequest> SynthesizeRequestList;
78 SynthesizeRequestList _requests;
81 bool _keepScratchFile;
84 #endif /* VOICESYNTHESIZER_HXX_ */