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.

265 lines
8.4 KiB

  1. // stdafx.h : include file for standard system include files,
  2. // or project specific include files that are used frequently, but
  3. // are changed infrequently
  4. //
  5. #if !defined(AFX_STDAFX_H__44183539_C02F_475B_9A56_7260EDD0A7F4__INCLUDED_)
  6. #define AFX_STDAFX_H__44183539_C02F_475B_9A56_7260EDD0A7F4__INCLUDED_
  7. #if _MSC_VER > 1000
  8. #pragma once
  9. #endif // _MSC_VER > 1000
  10. // TODO: reference additional headers your program requires here
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <atlbase.h>
  14. #include <sphelper.h>
  15. #include <spcollec.h>
  16. #include <sapi.h>
  17. #include <commonlx.h>
  18. #include <spttseng.h>
  19. struct PRONUNIT
  20. {
  21. ULONG phon_Len;
  22. WCHAR phon_Str[SP_MAX_PRON_LENGTH]; // Allo string
  23. ULONG POScount;
  24. ENGPARTOFSPEECH POScode[POS_MAX];
  25. };
  26. struct PRONRECORD
  27. {
  28. WCHAR orthStr[SP_MAX_WORD_LENGTH]; // Orth text
  29. WCHAR lemmaStr[SP_MAX_WORD_LENGTH]; // Root word
  30. ULONG pronType; // Pronunciation is lex or LTS
  31. PRONUNIT pronArray[2];
  32. ENGPARTOFSPEECH POSchoice;
  33. ENGPARTOFSPEECH XMLPartOfSpeech;
  34. bool hasAlt;
  35. ULONG altChoice;
  36. };
  37. //--- This struct is just used as a helper to initialize the PRONRECORD to all zeroes
  38. struct DebugPronRecord : PRONRECORD
  39. {
  40. public:
  41. DebugPronRecord() { ZeroMemory( (void*) this, sizeof( DebugPronRecord ) ); }
  42. operator =( PRONRECORD InRecord )
  43. {
  44. memcpy( this, &InRecord, sizeof( PRONRECORD ) );
  45. }
  46. };
  47. //--- This struct is used to replace the SPVCONTEXT struct for outputting to the debug streams -
  48. //--- cannot have any pointers in a struct which we will output as binary data...
  49. struct DebugContext
  50. {
  51. WCHAR Category[32];
  52. WCHAR Before[32];
  53. WCHAR After[32];
  54. public:
  55. DebugContext() { ZeroMemory( (void*) this, sizeof( DebugContext ) ); }
  56. operator =( SPVCONTEXT InContext )
  57. {
  58. if ( InContext.pCategory )
  59. {
  60. wcsncpy( Category, InContext.pCategory,
  61. wcslen(InContext.pCategory) > 31 ? 31 : wcslen(InContext.pCategory) );
  62. }
  63. if ( InContext.pBefore )
  64. {
  65. wcsncpy( Before, InContext.pBefore,
  66. wcslen(InContext.pBefore) > 31 ? 31 : wcslen(InContext.pBefore) );
  67. }
  68. if ( InContext.pAfter )
  69. {
  70. wcsncpy( After, InContext.pAfter,
  71. wcslen(InContext.pAfter) > 31 ? 31 : wcslen(InContext.pAfter) );
  72. }
  73. }
  74. };
  75. //--- This struct is used to replace the SPVSTATE struct for outputting to the debug streams -
  76. //--- cannot have any pointers in a struct which we will output as binary data...
  77. struct DebugState
  78. {
  79. SPVACTIONS eAction;
  80. LANGID LangID;
  81. WORD wReserved;
  82. long EmphAdj;
  83. long RateAdj;
  84. ULONG Volume;
  85. SPVPITCH PitchAdj;
  86. ULONG SilenceMSecs;
  87. SPPHONEID PhoneIds[64];
  88. ENGPARTOFSPEECH ePartOfSpeech;
  89. DebugContext Context;
  90. public:
  91. DebugState() { ZeroMemory( (void*) this, sizeof( DebugState ) ); }
  92. operator =( SPVSTATE InState )
  93. {
  94. eAction = InState.eAction;
  95. LangID = InState.LangID;
  96. wReserved = InState.wReserved;
  97. EmphAdj = InState.EmphAdj;
  98. RateAdj = InState.RateAdj;
  99. Volume = InState.Volume;
  100. PitchAdj = InState.PitchAdj;
  101. SilenceMSecs = InState.SilenceMSecs;
  102. ePartOfSpeech = (ENGPARTOFSPEECH) InState.ePartOfSpeech;
  103. Context = InState.Context;
  104. if ( InState.pPhoneIds )
  105. {
  106. wcsncpy( PhoneIds, InState.pPhoneIds,
  107. wcslen(InState.pPhoneIds) > 63 ? 63 : wcslen(InState.pPhoneIds) );
  108. }
  109. }
  110. };
  111. //--- This struct is used to replace the TTSWord struct for outputting to the debug streams -
  112. //--- cannot have any pointers in a struct which we will output as binary data...
  113. struct DebugWord
  114. {
  115. DebugState XmlState;
  116. WCHAR WordText[32];
  117. ULONG ulWordLen;
  118. WCHAR LemmaText[32];
  119. ULONG ulLemmaLen;
  120. SPPHONEID WordPron[64];
  121. ENGPARTOFSPEECH eWordPartOfSpeech;
  122. public:
  123. DebugWord() { ZeroMemory( (void*) this, sizeof( DebugWord ) ); }
  124. operator =( TTSWord InWord )
  125. {
  126. XmlState = *(InWord.pXmlState);
  127. if ( InWord.pWordText )
  128. {
  129. wcsncpy( WordText, InWord.pWordText, InWord.ulWordLen > 31 ? 31 : InWord.ulWordLen );
  130. }
  131. ulWordLen = InWord.ulWordLen;
  132. if ( InWord.pLemma )
  133. {
  134. wcsncpy( LemmaText, InWord.pLemma, InWord.ulLemmaLen > 31 ? 31 : InWord.ulLemmaLen );
  135. }
  136. ulLemmaLen = InWord.ulLemmaLen;
  137. if ( InWord.pWordPron )
  138. {
  139. wcsncpy( WordPron, InWord.pWordPron,
  140. wcslen( InWord.pWordPron ) > 63 ? 63 : wcslen( InWord.pWordPron ) );
  141. }
  142. eWordPartOfSpeech = InWord.eWordPartOfSpeech;
  143. }
  144. };
  145. struct DebugItemInfo
  146. {
  147. TTSItemType Type;
  148. public:
  149. DebugItemInfo() { ZeroMemory( (void*) this, sizeof( DebugItemInfo ) ); }
  150. operator =( TTSItemInfo InItemInfo )
  151. {
  152. Type = InItemInfo.Type;
  153. }
  154. };
  155. //--- This struct is used to replace the TTSSentItem struct for outputting to the debug streams -
  156. //--- cannot have any pointers in a struct which we will output as binary data...
  157. struct DebugSentItem
  158. {
  159. WCHAR ItemSrcText[32];
  160. ULONG ulItemSrcLen;
  161. ULONG ulItemSrcOffset;
  162. DebugWord Words[32];
  163. ULONG ulNumWords;
  164. ENGPARTOFSPEECH eItemPartOfSpeech;
  165. DebugItemInfo ItemInfo;
  166. public:
  167. DebugSentItem() { ZeroMemory( (void*) this, sizeof( DebugSentItem ) ); }
  168. operator =( TTSSentItem InItem )
  169. {
  170. if ( InItem.pItemSrcText )
  171. {
  172. wcsncpy( ItemSrcText, InItem.pItemSrcText, InItem.ulItemSrcLen > 31 ? 31 : InItem.ulItemSrcLen );
  173. }
  174. ulItemSrcLen = InItem.ulItemSrcLen;
  175. ulItemSrcOffset = InItem.ulItemSrcOffset;
  176. for ( ULONG i = 0; i < InItem.ulNumWords; i++ )
  177. {
  178. Words[i] = InItem.Words[i];
  179. }
  180. ulNumWords = InItem.ulNumWords;
  181. eItemPartOfSpeech = InItem.eItemPartOfSpeech;
  182. ItemInfo = *(InItem.pItemInfo);
  183. }
  184. };
  185. //--- This enumeration is used to index the array of IStreams used to write stuff to the debug file
  186. typedef enum
  187. {
  188. STREAM_WAVE = 0,
  189. STREAM_EPOCH,
  190. STREAM_UNIT,
  191. STREAM_WAVEINFO,
  192. STREAM_TOBI,
  193. STREAM_SENTENCEBREAKS,
  194. STREAM_NORMALIZEDTEXT,
  195. STREAM_LEXLOOKUP,
  196. STREAM_POSPOSSIBILITIES,
  197. STREAM_MORPHOLOGY,
  198. STREAM_LASTTYPE
  199. } STREAM_TYPE;
  200. //
  201. // String handling and conversion classes
  202. //
  203. /*** SPLSTR
  204. * This structure is for managing strings with known lengths
  205. */
  206. struct SPLSTR
  207. {
  208. WCHAR* pStr;
  209. int Len;
  210. };
  211. #define DEF_SPLSTR( s ) { L##s , sp_countof( s ) - 1 }
  212. //--- This enumeration should correspond to the previous one, and is used to name the array of IStreams
  213. //--- used to write stuff to the debug file
  214. static const SPLSTR StreamTypeStrings[] =
  215. {
  216. DEF_SPLSTR( "Wave" ),
  217. DEF_SPLSTR( "Epoch" ),
  218. DEF_SPLSTR( "Unit" ),
  219. DEF_SPLSTR( "WaveInfo" ),
  220. DEF_SPLSTR( "ToBI" ),
  221. DEF_SPLSTR( "SentenceBreaks" ),
  222. DEF_SPLSTR( "NormalizedText" ),
  223. DEF_SPLSTR( "LexLookup" ),
  224. DEF_SPLSTR( "PosPossibilities" ),
  225. DEF_SPLSTR( "Morphology" ),
  226. };
  227. //***************************
  228. // ToBI Constants
  229. //***************************
  230. // !H is removed from consideration in the first pass processing
  231. // !H can possibly be recovered from analysis of the labeling and
  232. // contour at later stages (tilt, prominence, pitch range, downstep)
  233. #define ACCENT_BASE 1
  234. enum TOBI_ACCENT
  235. {
  236. K_NOACC = 0,
  237. K_HSTAR = ACCENT_BASE, // peak rise / fall
  238. K_LSTAR, // acc syll nucleus valley early fall
  239. K_LSTARH, // late rise
  240. K_RSTAR, //
  241. K_LHSTAR, // early rise
  242. K_DHSTAR, //
  243. };
  244. //{{AFX_INSERT_LOCATION}}
  245. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  246. #endif // !defined(AFX_STDAFX_H__44183539_C02F_475B_9A56_7260EDD0A7F4__INCLUDED_)