Leaked source code of windows server 2003
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.

174 lines
5.8 KiB

  1. /******************************************************************************
  2. * Frontend.h *
  3. *------------*
  4. * This is the header file for the CFrontend implementation.
  5. *------------------------------------------------------------------------------
  6. * Copyright (C) 1999 Microsoft Corporation Date: 03/01/99
  7. * All Rights Reserved
  8. *
  9. *********************************************************************** MC ****/
  10. #ifndef Frontend_H
  11. #define Frontend_H
  12. #ifndef FeedChain_H
  13. #include "FeedChain.h"
  14. #endif
  15. #ifndef AlloOps_H
  16. #include "AlloOps.h"
  17. #endif
  18. #ifndef __spttseng_h__
  19. #include "spttseng.h"
  20. #endif
  21. #include "sapi.h"
  22. //static const float DISCRETE_BKPT = 0.6667f;
  23. static const float DISCRETE_BKPT = 0.3333f;
  24. //-----------------------------------------
  25. // Parse Next Sentence or Previous Sentence
  26. //-----------------------------------------
  27. enum DIRECTION
  28. {
  29. eNEXT = 0,
  30. ePREVIOUS = 1,
  31. };
  32. //------------------------------------------------------
  33. // Tag Values
  34. //------------------------------------------------------
  35. enum USER_VOLUME_VALUE
  36. {
  37. MIN_USER_VOL = 0,
  38. MAX_USER_VOL = 100,
  39. DEFAULT_USER_VOL = MAX_USER_VOL
  40. };
  41. enum USER_PITCH_VALUE
  42. {
  43. MIN_USER_PITCH = (-24),
  44. MAX_USER_PITCH = 24,
  45. DEFAULT_USER_PITCH = 0 // None
  46. };
  47. enum USER_EMPH_VALUE
  48. {
  49. MIN_USER_EMPH = (-10),
  50. MAX_USER_EMPH = 10,
  51. SAPI_USER_EMPH = 5,
  52. DEFAULT_USER_EMPH = 0 // None
  53. };
  54. //------------------------
  55. // ToBI phrasing
  56. //------------------------
  57. typedef struct
  58. {
  59. PROSODY_POS posClass;
  60. long start;
  61. long end;
  62. } TOBI_PHRASE;
  63. class CFrontend: public CFeedChain
  64. {
  65. public:
  66. //--------------------------------
  67. // Methods
  68. //--------------------------------
  69. CFrontend( );
  70. ~CFrontend( );
  71. void PrepareSpeech( IEnumSpSentence* pEnumSent, ISpTTSEngineSite* pOutputSite );
  72. HRESULT Init( IMSVoiceData* pVoiceDataObj, CFeedChain *pSrcObj, MSVOICEINFO* pVoiceInfo );
  73. private:
  74. HRESULT AlloToUnit( CAlloList *pAllos, UNITINFO *pu );
  75. HRESULT ParseSentence( DIRECTION eDirection );
  76. HRESULT TokensToAllo( CFETokenList *pTokList, CAlloList *pAllo );
  77. HRESULT GetSentenceTokens( DIRECTION eDirection );
  78. void GetItemControls( const SPVSTATE* pXmlState, CFEToken* pToken );
  79. void DisposeUnits( );
  80. void RecalcProsody();
  81. HRESULT ToBISymbols();
  82. void DoPhrasing();
  83. void DeleteTokenList();
  84. HRESULT UnitLookahead ();
  85. void AlloToUnitPitch( CAlloList *pAllos, UNITINFO *pu );
  86. void UnitToAlloDur( CAlloList *pAllos, UNITINFO *pu );
  87. float CntrlToRatio( long rateControl );
  88. PROSODY_POS GetPOSClass( ENGPARTOFSPEECH sapiPOS );
  89. bool StateQuoteProsody( CFEToken *pWordTok, TTSSentItem *pSentItem, bool fInsertSil );
  90. bool StartParenProsody( CFEToken *pWordTok, TTSSentItem *pSentItem, bool fInsertSil );
  91. bool EndParenProsody( CFEToken *pWordTok, TTSSentItem *pSentItem, bool fInsertSil );
  92. bool EmphSetup( CFEToken *pWordTok, TTSSentItem *pSentItem, bool fInsertSil );
  93. SPLISTPOS InsertSilenceAtTail( CFEToken *pWordTok, TTSSentItem *pSentItem, long msec );
  94. SPLISTPOS InsertSilenceAfterPos( CFEToken *pWordTok, SPLISTPOS position );
  95. SPLISTPOS InsertSilenceBeforePos( CFEToken *pWordTok, SPLISTPOS position );
  96. void DoWordAccent();
  97. void ExclamEmph();
  98. void ProsodyTemplates( SPLISTPOS clusterPos, TTSSentItem *pSentItem );
  99. long DoIntegerTemplate( SPLISTPOS *pClusterPos, TTSNumberItemInfo *pNInfo, long cWordCount );
  100. void DoNumByNumTemplate( SPLISTPOS *pClusterPos, long cWordCount );
  101. void DoCurrencyTemplate( SPLISTPOS clusterPos, TTSSentItem *pSentItem );
  102. void DoPhoneNumberTemplate( SPLISTPOS clusterPos, TTSSentItem *pSentItem );
  103. void DoTODTemplate( SPLISTPOS clusterPos, TTSSentItem *pSentItem );
  104. long DoFractionTemplate( SPLISTPOS *pClusterPos, TTSNumberItemInfo *pNInfo, long cWordCount );
  105. CFEToken *InsertPhoneSilenceAtSpace( SPLISTPOS *pClusterPos,
  106. BOUNDARY_SOURCE bndSrc,
  107. SILENCE_SOURCE silSrc );
  108. void InsertPhoneSilenceAtEnd( BOUNDARY_SOURCE bndSrc,
  109. SILENCE_SOURCE silSrc );
  110. void CalcSentenceLength();
  111. //--------------------------------
  112. // CFeedChain methods
  113. //--------------------------------
  114. virtual HRESULT NextData( void**pData, SPEECH_STATE *pSpeechState ) ;
  115. //--------------------------------
  116. // Members
  117. //--------------------------------
  118. UNITINFO* m_pUnits;
  119. ULONG m_unitCount;
  120. ULONG m_CurUnitIndex;
  121. SPEECH_STATE m_SpeechState;
  122. CFeedChain *m_pSrcObj;
  123. long m_VoiceWPM; // Voice defined speaking rate (wpm)
  124. float m_RateRatio_API; // API modulated speaking rate (ratio)
  125. float m_CurDurScale; // control tag (ratio)
  126. float m_RateRatio_BKPT; // Below this, add pauses (ratio)
  127. float m_RateRatio_PROSODY; // API modulated speaking rate (ratio)
  128. float m_BasePitch; // FROM VOICE: Baseline pitch in hz
  129. float m_PitchRange; // FROM VOICE: Pitch range in +/- octaves
  130. bool m_HasSpeech;
  131. CFETokenList m_TokList;
  132. long m_cNumOfWords;
  133. CPitchProsody m_PitchObj;
  134. IEnumSpSentence *m_pEnumSent;
  135. CDuration m_DurObj;
  136. CSyllableTagger m_SyllObj;
  137. IMSVoiceData* m_pVoiceDataObj;
  138. float m_ProsodyGain;
  139. float m_SampleRate;
  140. CAlloList *m_pAllos;
  141. bool m_fInQuoteProsody; // Special prosody mode
  142. bool m_fInParenProsody; // Special prosody mode
  143. float m_CurPitchOffs; // Pitch offset in octaves
  144. float m_CurPitchRange; // Pitch range scale (0 - 2.0)
  145. ISpTTSEngineSite *m_pOutputSite;
  146. };
  147. #endif //--- This must be the last line in the file