Debian Codegraph @

sapi/FliteTTSEngineObj/FliteTTSEngineObj.h

raw
1 /*************************************************************************/
2 /* */
3 /* Cepstral, LLC */
4 /* Copyright (c) 2001 */
5 /* All Rights Reserved. */
6 /* */
7 /* Permission is hereby granted, free of charge, to use and distribute */
8 /* this software and its documentation without restriction, including */
9 /* without limitation the rights to use, copy, modify, merge, publish, */
10 /* distribute, sublicense, and/or sell copies of this work, and to */
11 /* permit persons to whom this work is furnished to do so, subject to */
12 /* the following conditions: */
13 /* 1. The code must retain the above copyright notice, this list of */
14 /* conditions and the following disclaimer. */
15 /* 2. Any modifications must be clearly marked as such. */
16 /* 3. Original authors' names are not deleted. */
17 /* 4. The authors' names are not used to endorse or promote products */
18 /* derived from this software without specific prior written */
19 /* permission. */
20 /* */
21 /* CEPSTRAL, LLC AND THE CONTRIBUTORS TO THIS WORK DISCLAIM ALL */
22 /* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED */
23 /* WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL */
24 /* CEPSTRAL, LLC NOR THE CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, */
25 /* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER */
26 /* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION */
27 /* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR */
28 /* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
29 /* */
30 /*************************************************************************/
31 /* Author: David Huggins-Daines ([email protected]) */
32 /* Date: December 2001 */
33 /*************************************************************************/
34 /* */
35 /* FliteTTSEngineObj.h: implementation of SAPI interface to Flite */
36 /* */
37 /*************************************************************************/
38
39 #ifndef __FLITETTSENGINEOBJ_H_
40 #define __FLITETTSENGINEOBJ_H_
41
42 #include <atlbase.h>
43 extern CComModule _Module;
44 #include <atlcom.h>
45 #include <spddkhlp.h>
46 #include <spcollec.h>
47 #include "flite.h"
48
49 class ATL_NO_VTABLE CFliteTTSEngineObj :
50 public CComObjectRootEx<CComMultiThreadModel>,
51 public ISpTTSEngine,
52 public ISpObjectWithToken
53 {
54 public:
55 CFliteTTSEngineObj() {
56 flite_init();
57 curr_utt = NULL;
58 curr_vox = NULL;
59 }
60 ~CFliteTTSEngineObj() {
61 if (curr_utt) delete_utterance(curr_utt);
62 if (unregfunc && curr_vox) (*unregfunc)(curr_vox);
63 }
64
65 /* ISpObjectWithToken methods */
66 public:
67 STDMETHODIMP SetObjectToken(ISpObjectToken * pToken);
68 STDMETHODIMP GetObjectToken(ISpObjectToken** ppToken)
69 { return SpGenericGetObjectToken(ppToken, vox_token); }
70
71 /* ISpTTSEngine methods */
72 public:
73 STDMETHOD(Speak)(DWORD dwSpeakFlags,
74 REFGUID rguidFormatId, const WAVEFORMATEX * pWaveFormatEx,
75 const SPVTEXTFRAG* pTextFragList, ISpTTSEngineSite* pOutputSite);
76 STDMETHOD(GetOutputFormat)(const GUID * pTargetFormatId,
77 const WAVEFORMATEX * pTargetWaveFormatEx,
78 GUID * pDesiredFormatId,
79 WAVEFORMATEX ** ppCoMemDesiredWaveFormatEx);
80
81 /* Implementation stuff */
82 protected:
83 /* These get set by a subclass's constructor. That's not the
84 proper C++ way to do this, but I do not care. */
85 cst_voice *(*regfunc)(const char *);
86 void (*unregfunc)(cst_voice *);
87 int (*phonemefunc)(cst_item *);
88 int (*visemefunc)(cst_item *);
89 int (*featurefunc)(cst_item *);
90 cst_val *(*pronouncefunc)(SPPHONEID *);
91
92 /* SAPI's use of the term "token" is quite unfortunate. */
93 CComPtr<ISpObjectToken> vox_token;
94 cst_voice *curr_vox;
95
96 /* Synthesis state variables */
97 cst_utterance *curr_utt;
98 cst_relation *tok_rel;
99 const SPVTEXTFRAG *curr_frag;
100 ISpTTSEngineSite *site;
101 ULONGLONG bcount;
102 int sentence_start;
103 int sentence_skip;
104 int aborted;
105 int volume;
106
107 private:
108 /* These have no earthly business being in a header file, but
109 they need access to the instance data. */
110 void start_new_utt();
111 void synth_one_utt();
112 void send_item_events();
113 void send_sentence_event(int fpos);
114 void get_actions_and_do_them();
115
116 int next_viseme(cst_item *s);
117 int viseme_len(cst_item *s);
118 int phoneme_len(cst_item *s);
119
120 void speak_frag();
121 void spell_frag();
122 void pronounce_frag();
123 void silence_frag();
124 void set_bookmark();
125 };
126
127 #endif //__FLITETTSENGINEOBJ_H_