-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttsengobj.h
108 lines (83 loc) · 3.09 KB
/
ttsengobj.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/******************************************************************************
* TtsEngObj.h *
*-------------*
* This is the header file for the sample CTTSEngObj class definition.
*------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*
******************************************************************************/
#ifndef TtsEngObj_h
#define TtsEngObj_h
//--- Additional includes
#ifndef __TtsEng_h__
#include "ttseng.h"
#endif
#include <stdio.h>
#include "eci.h"
#ifndef SPDDKHLP_h
#include <spddkhlp.h>
#endif
#ifndef SPCollec_h
#include <spcollec.h>
#endif
#include "resource.h"
//=== Constants ====================================================
//=== Class, Enum, Struct and Union Declarations ===================
//=== Enumerated Set Definitions ===================================
//=== Function Type Definitions ====================================
//=== Class, Struct and Union Definitions ==========================
/*** CTTSEngObj COM object ********************************
*/
class ATL_NO_VTABLE CTTSEngObj :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CTTSEngObj, &CLSID_SampleTTSEngine>,
public ISpTTSEngine,
public ISpObjectWithToken
{
/*=== ATL Setup ===*/
public:
DECLARE_REGISTRY_RESOURCEID(IDR_SAMPLETTSENGINE)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CTTSEngObj)
COM_INTERFACE_ENTRY(ISpTTSEngine)
COM_INTERFACE_ENTRY(ISpObjectWithToken)
END_COM_MAP()
/*=== Methods =======*/
public:
/*--- Constructors/Destructors ---*/
HRESULT FinalConstruct();
void FinalRelease();
/*=== Interfaces ====*/
public:
//--- ISpObjectWithToken ----------------------------------
STDMETHODIMP SetObjectToken( ISpObjectToken * pToken );
STDMETHODIMP GetObjectToken( ISpObjectToken ** ppToken )
{ return SpGenericGetObjectToken( ppToken, m_cpToken ); }
//--- ISpTTSEngine --------------------------------------------
STDMETHOD(Speak)( DWORD dwSpeakFlags,
REFGUID rguidFormatId, const WAVEFORMATEX * pWaveFormatEx,
const SPVTEXTFRAG* pTextFragList, ISpTTSEngineSite* pOutputSite );
STDMETHOD(GetOutputFormat)( const GUID * pTargetFormatId, const WAVEFORMATEX * pTargetWaveFormatEx,
GUID * pDesiredFormatId, WAVEFORMATEX ** ppCoMemDesiredWaveFormatEx );
/*=== Member Data ===*/
private:
CComPtr<ISpObjectToken> m_cpToken;
ISpTTSEngineSite *m_OutputSite;
//Convert SAPI parameters to ECI parameters
int SAPI2ECIRate(int rate);
int SAPI2ECIPitch(int pitch, int BassPitch);
int SAPI2ECIRange(int range, int BassRange);
//Handle to ECI
ECIHand engine;
//Input buffer
char *text2speak;
//Output buffer
short buffer[4096];
// ECI callback
static ECICallbackReturn callback(ECIHand hEngine, enum ECIMessage Msg, long lParam, void *pData);
//ECI settings
unsigned long m_lang;
unsigned long m_voice;
unsigned long m_samplerate;
};
#endif //--- This must be the last line in the file