eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ttsengobj.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /******************************************************************************
  2. * TtsEngObj.h *
  3. *-------------*
  4. * This is the header file for the sample CTTSEngObj class definition.
  5. *------------------------------------------------------------------------------
  6. * Copyright (c) Microsoft Corporation. All rights reserved.
  7. *
  8. ******************************************************************************/
  9. #ifndef TtsEngObj_h
  10. #define TtsEngObj_h
  11. //--- Additional includes
  12. #ifndef __TtsEng_h__
  13. #include "ttseng.h"
  14. #endif
  15. #ifndef SPDDKHLP_h
  16. #include <spddkhlp.h>
  17. #endif
  18. #ifndef SPCollec_h
  19. #include <spcollec.h>
  20. #endif
  21. #include "resource.h"
  22. __declspec( dllexport )int FAR PASCAL _export CompileDictionary(const char *voice, const char *path_log);
  23. //=== Constants ====================================================
  24. //=== Class, Enum, Struct and Union Declarations ===================
  25. //=== Enumerated Set Definitions ===================================
  26. //=== Function Type Definitions ====================================
  27. //=== Class, Struct and Union Definitions ==========================
  28. /*** CSentItem
  29. * This object is a helper class
  30. */
  31. class CSentItem
  32. {
  33. public:
  34. CSentItem() { memset( this, 0, sizeof(*this) ); }
  35. CSentItem( CSentItem& Other ) { memcpy( this, &Other, sizeof( Other ) ); }
  36. /*--- Data members ---*/
  37. const SPVSTATE* pXmlState;
  38. LPCWSTR pItem;
  39. ULONG ulItemLen;
  40. ULONG ulItemSrcOffset; // Original source character position
  41. ULONG ulItemSrcLen; // Length of original source item in characters
  42. };
  43. typedef CSPList<CSentItem,CSentItem&> CItemList;
  44. /*** CTTSEngObj COM object ********************************
  45. */
  46. class ATL_NO_VTABLE CTTSEngObj :
  47. public CComObjectRootEx<CComMultiThreadModel>,
  48. public CComCoClass<CTTSEngObj, &CLSID_SampleTTSEngine>,
  49. public ISpTTSEngine,
  50. public ISpObjectWithToken
  51. {
  52. /*=== ATL Setup ===*/
  53. public:
  54. DECLARE_REGISTRY_RESOURCEID(IDR_SAMPLETTSENGINE)
  55. DECLARE_PROTECT_FINAL_CONSTRUCT()
  56. BEGIN_COM_MAP(CTTSEngObj)
  57. COM_INTERFACE_ENTRY(ISpTTSEngine)
  58. COM_INTERFACE_ENTRY(ISpObjectWithToken)
  59. END_COM_MAP()
  60. /*=== Methods =======*/
  61. public:
  62. /*--- Constructors/Destructors ---*/
  63. HRESULT FinalConstruct();
  64. void FinalRelease();
  65. /*=== Interfaces ====*/
  66. public:
  67. //--- ISpObjectWithToken ----------------------------------
  68. STDMETHODIMP SetObjectToken( ISpObjectToken * pToken );
  69. STDMETHODIMP GetObjectToken( ISpObjectToken ** ppToken )
  70. { return SpGenericGetObjectToken( ppToken, m_cpToken ); }
  71. //--- ISpTTSEngine --------------------------------------------
  72. STDMETHOD(Speak)( DWORD dwSpeakFlags,
  73. REFGUID rguidFormatId, const WAVEFORMATEX * pWaveFormatEx,
  74. const SPVTEXTFRAG* pTextFragList, ISpTTSEngineSite* pOutputSite );
  75. STDMETHOD(GetOutputFormat)( const GUID * pTargetFormatId, const WAVEFORMATEX * pTargetWaveFormatEx,
  76. GUID * pDesiredFormatId, WAVEFORMATEX ** ppCoMemDesiredWaveFormatEx );
  77. HRESULT CheckActions( ISpTTSEngineSite* pOutputSite );
  78. int ProcessFragList(const SPVTEXTFRAG* pTextFragList, wchar_t *pW, ISpTTSEngineSite* pOutputSite, int *n_text);
  79. private:
  80. /*--- Non interface methods ---*/
  81. /*=== Member Data ===*/
  82. private:
  83. CComPtr<ISpObjectToken> m_cpToken;
  84. HANDLE m_hVoiceData;
  85. void* m_pVoiceData;
  86. //--- Voice (word/audio data) list
  87. // Note: You will probably have something more sophisticated here
  88. // we are just trying to keep it simple for the example.
  89. VOICEITEM* m_pWordList;
  90. ULONG m_ulNumWords;
  91. //--- Working variables to walk the text fragment list during Speak()
  92. const SPVTEXTFRAG* m_pCurrFrag;
  93. const WCHAR* m_pNextChar;
  94. const WCHAR* m_pEndChar;
  95. ULONGLONG m_ullAudioOff;
  96. };
  97. #endif //--- This must be the last line in the file