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.

2198 lines
72 KiB

  1. /****************************************************************************
  2. * sapi.idl
  3. *
  4. * This is the interface definition file for the Microsoft Speech API
  5. * Version 5.0.
  6. *
  7. * Copyright (c) Microsoft Corporation. All rights reserved.
  8. *****************************************************************************/
  9. //--- Compiler Directive ----------------------------------------------------
  10. cpp_quote("#pragma warning(disable:4201) // Allow nameless structs/unions")
  11. //--- Includes --------------------------------------------------------------
  12. import "oaidl.idl";
  13. import "ocidl.idl";
  14. //--- Locally scoped define for LANGID
  15. #ifndef LANGID
  16. #define LANGID WORD
  17. #endif
  18. //--- Link with sapi.lib
  19. cpp_quote("#pragma comment(lib, \"sapi.lib\")")
  20. //--- Forward and External Declarations -------------------------------------
  21. cpp_quote("#if 0") // Ignore our definition in the .H file
  22. typedef [restricted, hidden] struct WAVEFORMATEX
  23. {
  24. WORD wFormatTag; /* format type */
  25. WORD nChannels; /* number of channels (i.e. mono, stereo...) */
  26. DWORD nSamplesPerSec; /* sample rate */
  27. DWORD nAvgBytesPerSec; /* for buffer estimation */
  28. WORD nBlockAlign; /* block size of data */
  29. WORD wBitsPerSample; /* Number of bits per sample of mono data */
  30. WORD cbSize; /* The count in bytes of the size of
  31. extra information (after cbSize) */
  32. } WAVEFORMATEX;
  33. cpp_quote("#else")
  34. cpp_quote("#include <mmsystem.h>")
  35. cpp_quote("#endif")
  36. //--- Notifications
  37. interface ISpNotifySource;
  38. interface ISpNotifySink;
  39. interface ISpNotifyTranslator;
  40. //--- Object tokens
  41. interface ISpDataKey;
  42. interface ISpObjectTokenCategory;
  43. interface ISpObjectToken;
  44. interface IEnumSpObjectTokens;
  45. interface ISpObjectWithToken;
  46. //--- Resource management
  47. interface ISpResourceManager;
  48. //--- Speech specific events
  49. interface ISpEventSource;
  50. interface ISpEventSink;
  51. //--- Audio streams
  52. interface ISpStreamFormat;
  53. interface ISpStream;
  54. interface ISpStreamFormatConverter;
  55. interface ISpAudio;
  56. interface ISpMMSysAudio;
  57. interface ISpTranscript;
  58. //--- TTS interface
  59. interface ISpVoice;
  60. //--- SR interfaces
  61. interface ISpRecoResult;
  62. interface ISpRecoContext;
  63. interface ISpRecognizer;
  64. interface ISpProperties;
  65. //--- Lexicon interfaces
  66. interface ISpLexicon;
  67. //--- Phone Converter
  68. interface ISpPhoneConverter;
  69. //--- Phrase interface
  70. interface ISpPhrase;
  71. //
  72. //--- Constants -------------------------------------------------------------
  73. //
  74. //--- DataKey locations
  75. typedef [hidden] enum SPDATAKEYLOCATION
  76. {
  77. SPDKL_DefaultLocation = 0,
  78. SPDKL_CurrentUser = 1,
  79. SPDKL_LocalMachine = 2,
  80. SPDKL_CurrentConfig = 5
  81. } SPDATAKEYLOCATION;
  82. //--- TokenUI constants
  83. cpp_quote("#define SPDUI_EngineProperties L\"EngineProperties\"")
  84. cpp_quote("#define SPDUI_AddRemoveWord L\"AddRemoveWord\"")
  85. cpp_quote("#define SPDUI_UserTraining L\"UserTraining\"")
  86. cpp_quote("#define SPDUI_MicTraining L\"MicTraining\"")
  87. cpp_quote("#define SPDUI_RecoProfileProperties L\"RecoProfileProperties\"")
  88. cpp_quote("#define SPDUI_AudioProperties L\"AudioProperties\"")
  89. cpp_quote("#define SPDUI_AudioVolume L\"AudioVolume\"")
  90. cpp_quote("#define SPDUI_UserEnrollment L\"UserEnrollment\"")
  91. //--- Data formats - these are used by the CSpStreamFormat class in sphelper.h
  92. typedef [hidden] enum SPSTREAMFORMAT
  93. {
  94. SPSF_Default = -1,
  95. SPSF_NoAssignedFormat = 0, // Similar to GUID_NULL
  96. SPSF_Text,
  97. SPSF_NonStandardFormat, // Non-SAPI 5.0 standard format with no WAVEFORMATEX description
  98. SPSF_ExtendedAudioFormat, // Non-SAPI 5.0 standard format but has WAVEFORMATEX description
  99. // Standard PCM wave formats
  100. SPSF_8kHz8BitMono,
  101. SPSF_8kHz8BitStereo,
  102. SPSF_8kHz16BitMono,
  103. SPSF_8kHz16BitStereo,
  104. SPSF_11kHz8BitMono,
  105. SPSF_11kHz8BitStereo,
  106. SPSF_11kHz16BitMono,
  107. SPSF_11kHz16BitStereo,
  108. SPSF_12kHz8BitMono,
  109. SPSF_12kHz8BitStereo,
  110. SPSF_12kHz16BitMono,
  111. SPSF_12kHz16BitStereo,
  112. SPSF_16kHz8BitMono,
  113. SPSF_16kHz8BitStereo,
  114. SPSF_16kHz16BitMono,
  115. SPSF_16kHz16BitStereo,
  116. SPSF_22kHz8BitMono,
  117. SPSF_22kHz8BitStereo,
  118. SPSF_22kHz16BitMono,
  119. SPSF_22kHz16BitStereo,
  120. SPSF_24kHz8BitMono,
  121. SPSF_24kHz8BitStereo,
  122. SPSF_24kHz16BitMono,
  123. SPSF_24kHz16BitStereo,
  124. SPSF_32kHz8BitMono,
  125. SPSF_32kHz8BitStereo,
  126. SPSF_32kHz16BitMono,
  127. SPSF_32kHz16BitStereo,
  128. SPSF_44kHz8BitMono,
  129. SPSF_44kHz8BitStereo,
  130. SPSF_44kHz16BitMono,
  131. SPSF_44kHz16BitStereo,
  132. SPSF_48kHz8BitMono,
  133. SPSF_48kHz8BitStereo,
  134. SPSF_48kHz16BitMono,
  135. SPSF_48kHz16BitStereo,
  136. // TrueSpeech format
  137. SPSF_TrueSpeech_8kHz1BitMono,
  138. // A-Law formats
  139. SPSF_CCITT_ALaw_8kHzMono,
  140. SPSF_CCITT_ALaw_8kHzStereo,
  141. SPSF_CCITT_ALaw_11kHzMono,
  142. SPSF_CCITT_ALaw_11kHzStereo,
  143. SPSF_CCITT_ALaw_22kHzMono,
  144. SPSF_CCITT_ALaw_22kHzStereo,
  145. SPSF_CCITT_ALaw_44kHzMono,
  146. SPSF_CCITT_ALaw_44kHzStereo,
  147. // u-Law formats
  148. SPSF_CCITT_uLaw_8kHzMono,
  149. SPSF_CCITT_uLaw_8kHzStereo,
  150. SPSF_CCITT_uLaw_11kHzMono,
  151. SPSF_CCITT_uLaw_11kHzStereo,
  152. SPSF_CCITT_uLaw_22kHzMono,
  153. SPSF_CCITT_uLaw_22kHzStereo,
  154. SPSF_CCITT_uLaw_44kHzMono,
  155. SPSF_CCITT_uLaw_44kHzStereo,
  156. // ADPCM formats
  157. SPSF_ADPCM_8kHzMono,
  158. SPSF_ADPCM_8kHzStereo,
  159. SPSF_ADPCM_11kHzMono,
  160. SPSF_ADPCM_11kHzStereo,
  161. SPSF_ADPCM_22kHzMono,
  162. SPSF_ADPCM_22kHzStereo,
  163. SPSF_ADPCM_44kHzMono,
  164. SPSF_ADPCM_44kHzStereo,
  165. // GSM 6.10 formats
  166. SPSF_GSM610_8kHzMono,
  167. SPSF_GSM610_11kHzMono,
  168. SPSF_GSM610_22kHzMono,
  169. SPSF_GSM610_44kHzMono,
  170. SPSF_NUM_FORMATS
  171. } SPSTREAMFORMAT;
  172. cpp_quote("EXTERN_C const GUID SPDFID_Text;")
  173. cpp_quote("EXTERN_C const GUID SPDFID_WaveFormatEx;")
  174. //--- Root of registry entries for speech use
  175. cpp_quote("#define SPREG_USER_ROOT L\"HKEY_CURRENT_USER\\\\SOFTWARE\\\\Microsoft\\\\Speech\"")
  176. cpp_quote("#define SPREG_LOCAL_MACHINE_ROOT L\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Speech\"")
  177. //--- Categories for speech resource management
  178. cpp_quote("#define SPCAT_AUDIOOUT L\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\AudioOutput\"")
  179. cpp_quote("#define SPCAT_AUDIOIN L\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\AudioInput\"")
  180. cpp_quote("#define SPCAT_VOICES L\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\Voices\"")
  181. cpp_quote("#define SPCAT_RECOGNIZERS L\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\Recognizers\"")
  182. cpp_quote("#define SPCAT_APPLEXICONS L\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\AppLexicons\"")
  183. cpp_quote("#define SPCAT_PHONECONVERTERS L\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\PhoneConverters\"")
  184. cpp_quote("#define SPCAT_RECOPROFILES L\"HKEY_CURRENT_USER\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\RecoProfiles\"")
  185. //--- Specific token ids of interest
  186. cpp_quote("#define SPMMSYS_AUDIO_IN_TOKEN_ID L\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\AudioInput\\\\TokenEnums\\\\MMAudioIn\\\\\"")
  187. cpp_quote("#define SPMMSYS_AUDIO_OUT_TOKEN_ID L\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\AudioOutput\\\\TokenEnums\\\\MMAudioOut\\\\\"")
  188. cpp_quote("#define SPCURRENT_USER_LEXICON_TOKEN_ID L\"HKEY_CURRENT_USER\\\\SOFTWARE\\\\Microsoft\\\\Speech\\\\CurrentUserLexicon\"")
  189. //--- Standard token values
  190. cpp_quote("#define SPTOKENVALUE_CLSID L\"CLSID\"")
  191. cpp_quote("#define SPTOKENKEY_FILES L\"Files\"")
  192. cpp_quote("#define SPTOKENKEY_UI L\"UI\"")
  193. cpp_quote("#define SPTOKENKEY_ATTRIBUTES L\"Attributes\"")
  194. //--- Standard voice category values
  195. cpp_quote("#define SPVOICECATEGORY_TTSRATE L\"DefaultTTSRate\"")
  196. //--- Standard SR Engine properties
  197. cpp_quote("#define SPPROP_RESOURCE_USAGE L\"ResourceUsage\"")
  198. cpp_quote("#define SPPROP_HIGH_CONFIDENCE_THRESHOLD L\"HighConfidenceThreshold\"")
  199. cpp_quote("#define SPPROP_NORMAL_CONFIDENCE_THRESHOLD L\"NormalConfidenceThreshold\"")
  200. cpp_quote("#define SPPROP_LOW_CONFIDENCE_THRESHOLD L\"LowConfidenceThreshold\"")
  201. cpp_quote("#define SPPROP_RESPONSE_SPEED L\"ResponseSpeed\"")
  202. cpp_quote("#define SPPROP_COMPLEX_RESPONSE_SPEED L\"ComplexResponseSpeed\"")
  203. cpp_quote("#define SPPROP_ADAPTATION_ON L\"AdaptationOn\"")
  204. //--- Standard SAPI Recognition Topics
  205. cpp_quote("#define SPTOPIC_SPELLING L\"Spelling\"")
  206. // CFG Wildcard token
  207. cpp_quote("#define SPWILDCARD L\"...\"")
  208. // CFG Dication token
  209. cpp_quote("#define SPDICTATION L\"*\"")
  210. cpp_quote("#define SPINFDICTATION L\"*+\"")
  211. // CFG confidence scores
  212. const signed char SP_LOW_CONFIDENCE = -1;
  213. const signed char SP_NORMAL_CONFIDENCE = 0;
  214. const signed char SP_HIGH_CONFIDENCE = +1;
  215. // CFG default weight
  216. const float DEFAULT_WEIGHT = 1.0;
  217. // Lexicon word and pronunciation limits
  218. const ULONG SP_MAX_WORD_LENGTH = 128;
  219. const ULONG SP_MAX_PRON_LENGTH = 384;
  220. //
  221. //--- Interface definitions -------------------------------------------------
  222. //
  223. //--- ISpNotifyCallback -----------------------------------------------------
  224. cpp_quote("#if defined(__cplusplus)")
  225. cpp_quote("interface ISpNotifyCallback")
  226. cpp_quote("{")
  227. cpp_quote("virtual HRESULT STDMETHODCALLTYPE NotifyCallback(")
  228. cpp_quote(" WPARAM wParam,")
  229. cpp_quote(" LPARAM lParam) = 0;")
  230. cpp_quote("};")
  231. cpp_quote("#else")
  232. typedef void * ISpNotifyCallback;
  233. cpp_quote("#endif")
  234. cpp_quote("#if 0")
  235. typedef void * SPNOTIFYCALLBACK;
  236. cpp_quote("#else")
  237. cpp_quote("typedef void __stdcall SPNOTIFYCALLBACK(WPARAM wParam, LPARAM lParam);")
  238. cpp_quote("#endif")
  239. //--- ISpNotifySource -------------------------------------------------------
  240. [
  241. object,
  242. uuid(5EFF4AEF-8487-11D2-961C-00C04F8EE628),
  243. helpstring("ISpNotifySource Interface"),
  244. pointer_default(unique),
  245. restricted
  246. ]
  247. interface ISpNotifySource : IUnknown
  248. {
  249. HRESULT SetNotifySink([in] ISpNotifySink * pNotifySink);
  250. [local] HRESULT SetNotifyWindowMessage(
  251. [in] HWND hWnd,
  252. [in] UINT Msg,
  253. [in] WPARAM wParam,
  254. [in] LPARAM lParam);
  255. [local] HRESULT SetNotifyCallbackFunction(
  256. [in] SPNOTIFYCALLBACK * pfnCallback,
  257. [in] WPARAM wParam,
  258. [in] LPARAM lParam);
  259. [local] HRESULT SetNotifyCallbackInterface(
  260. [in] ISpNotifyCallback * pSpCallback,
  261. [in] WPARAM wParam,
  262. [in] LPARAM lParam);
  263. [local] HRESULT SetNotifyWin32Event(void);
  264. [local] HRESULT WaitForNotifyEvent([in] DWORD dwMilliseconds);
  265. [local] HANDLE GetNotifyEventHandle();
  266. }
  267. //--- ISpNotifySink ---------------------------------------------------------
  268. [
  269. object,
  270. uuid(259684DC-37C3-11D2-9603-00C04F8EE628),
  271. helpstring("ISpNotifySink Interface"),
  272. pointer_default(unique),
  273. restricted
  274. ]
  275. interface ISpNotifySink : IUnknown
  276. {
  277. HRESULT Notify(void);
  278. }
  279. //--- ISpNotifyTranslator ---------------------------------------------------
  280. [
  281. object,
  282. uuid(ACA16614-5D3D-11D2-960E-00C04F8EE628),
  283. helpstring("ISpNotifyTranslator Interface"),
  284. pointer_default(unique),
  285. local,
  286. restricted
  287. ]
  288. interface ISpNotifyTranslator : ISpNotifySink
  289. {
  290. HRESULT InitWindowMessage(
  291. [in] HWND hWnd,
  292. [in] UINT Msg,
  293. [in] WPARAM wParam,
  294. [in] LPARAM lParam);
  295. HRESULT InitCallback(
  296. [in] SPNOTIFYCALLBACK * pfnCallback,
  297. [in] WPARAM wParam,
  298. [in] LPARAM lParam);
  299. HRESULT InitSpNotifyCallback(
  300. [in] ISpNotifyCallback * pSpCallback,
  301. [in] WPARAM wParam,
  302. [in] LPARAM lParam);
  303. HRESULT InitWin32Event(
  304. HANDLE hEvent,
  305. BOOL fCloseHandleOnRelease);
  306. HRESULT Wait([in] DWORD dwMilliseconds);
  307. HANDLE GetEventHandle();
  308. }
  309. //--- ISpDataKey ------------------------------------------------------------
  310. [
  311. object,
  312. uuid(14056581-E16C-11D2-BB90-00C04F8EE6C0),
  313. helpstring("ISpDataKey Interface"),
  314. pointer_default(unique),
  315. restricted
  316. ]
  317. interface ISpDataKey : IUnknown
  318. {
  319. HRESULT SetData( const WCHAR * pszValueName, ULONG cbData, const BYTE * pData);
  320. HRESULT GetData( const WCHAR * pszValueName, ULONG * pcbData, BYTE * pData);
  321. HRESULT SetStringValue( const WCHAR * pszValueName, const WCHAR * pszValue );
  322. HRESULT GetStringValue( const WCHAR * pszValueName, WCHAR ** ppszValue);
  323. HRESULT SetDWORD(const WCHAR * pszValueName, DWORD dwValue );
  324. HRESULT GetDWORD(const WCHAR * pszValueName, DWORD *pdwValue );
  325. HRESULT OpenKey(const WCHAR * pszSubKeyName, ISpDataKey ** ppSubKey);
  326. HRESULT CreateKey(const WCHAR * pszSubKey, ISpDataKey ** ppSubKey);
  327. HRESULT DeleteKey(const WCHAR * pszSubKey);
  328. HRESULT DeleteValue(const WCHAR * pszValueName);
  329. HRESULT EnumKeys(ULONG Index, WCHAR ** ppszSubKeyName);
  330. HRESULT EnumValues(ULONG Index, WCHAR ** ppszValueName);
  331. };
  332. //--- ISpRegDataKey ---------------------------------------------------------
  333. [
  334. object,
  335. uuid(92A66E2B-C830-4149-83DF-6FC2BA1E7A5B),
  336. helpstring("ISpRegDataKey"),
  337. pointer_default(unique),
  338. restricted
  339. ]
  340. interface ISpRegDataKey : ISpDataKey
  341. {
  342. [local] HRESULT SetKey([in] HKEY hkey, [in] BOOL fReadOnly);
  343. }
  344. //--- ISpObjectTokenCategory ------------------------------------------------
  345. [
  346. object,
  347. uuid(2D3D3845-39AF-4850-BBF9-40B49780011D),
  348. helpstring("ISpObjectTokenCategory"),
  349. pointer_default(unique),
  350. restricted
  351. ]
  352. interface ISpObjectTokenCategory : ISpDataKey
  353. {
  354. HRESULT SetId([in] const WCHAR * pszCategoryId, BOOL fCreateIfNotExist);
  355. HRESULT GetId([out] WCHAR ** ppszCoMemCategoryId);
  356. HRESULT GetDataKey(SPDATAKEYLOCATION spdkl, ISpDataKey ** ppDataKey);
  357. HRESULT EnumTokens(
  358. [in, string] const WCHAR * pzsReqAttribs,
  359. [in, string] const WCHAR * pszOptAttribs,
  360. [out] IEnumSpObjectTokens ** ppEnum);
  361. HRESULT SetDefaultTokenId([in] const WCHAR * pszTokenId);
  362. HRESULT GetDefaultTokenId([out] WCHAR ** ppszCoMemTokenId);
  363. };
  364. //--- ISpObjectToken --------------------------------------------------------
  365. [
  366. object,
  367. uuid(14056589-E16C-11D2-BB90-00C04F8EE6C0),
  368. helpstring("ISpObjectToken Interface"),
  369. pointer_default(unique),
  370. restricted
  371. ]
  372. interface ISpObjectToken : ISpDataKey
  373. {
  374. HRESULT SetId(const WCHAR * pszCategoryId, const WCHAR * pszTokenId, BOOL fCreateIfNotExist);
  375. HRESULT GetId(WCHAR ** ppszCoMemTokenId);
  376. HRESULT GetCategory(ISpObjectTokenCategory ** ppTokenCategory);
  377. HRESULT CreateInstance(
  378. [in] IUnknown * pUnkOuter,
  379. [in] DWORD dwClsContext,
  380. [in] REFIID riid,
  381. [out, iid_is(riid)] void ** ppvObject);
  382. HRESULT GetStorageFileName(
  383. [in] REFCLSID clsidCaller,
  384. [in] const WCHAR * pszValueName,
  385. [in] const WCHAR * pszFileNameSpecifier,
  386. [in] ULONG nFolder, // Same as SHGetFolderPath -- If non-zero, must set CSIDL_FLAG_CREATE
  387. [out] WCHAR ** ppszFilePath);
  388. HRESULT RemoveStorageFileName(
  389. [in] REFCLSID clsidCaller,
  390. [in] const WCHAR * pszKeyName,
  391. [in] BOOL fDeleteFile);
  392. HRESULT Remove(const CLSID * pclsidCaller);
  393. [local] HRESULT IsUISupported(
  394. [in] const WCHAR * pszTypeOfUI,
  395. [in] void * pvExtraData,
  396. [in] ULONG cbExtraData,
  397. [in] IUnknown * punkObject,
  398. [out] BOOL *pfSupported);
  399. [local] HRESULT DisplayUI(
  400. [in] HWND hwndParent,
  401. [in] const WCHAR * pszTitle,
  402. [in] const WCHAR * pszTypeOfUI,
  403. [in] void * pvExtraData,
  404. [in] ULONG cbExtraData,
  405. [in] IUnknown * punkObject);
  406. HRESULT MatchesAttributes(
  407. [in] const WCHAR * pszAttributes,
  408. [out] BOOL *pfMatches);
  409. };
  410. [
  411. object,
  412. uuid(B8AAB0CF-346F-49D8-9499-C8B03F161D51),
  413. helpstring("ISpObjectTokenInit Interface"),
  414. pointer_default(unique),
  415. restricted
  416. ]
  417. interface ISpObjectTokenInit : ISpObjectToken
  418. {
  419. HRESULT InitFromDataKey(
  420. [in] const WCHAR * pszCategoryId,
  421. [in] const WCHAR * pszTokenId,
  422. [in] ISpDataKey * pDataKey);
  423. };
  424. //--- IEnumSpObjectTokens ---------------------------------------------------
  425. // This interface is used to enumerate speech object tokens
  426. [
  427. object,
  428. uuid(06B64F9E-7FDA-11D2-B4F2-00C04F797396),
  429. helpstring("IEnumSpObjectTokens Interface"),
  430. pointer_default(unique),
  431. restricted
  432. ]
  433. interface IEnumSpObjectTokens : IUnknown
  434. {
  435. HRESULT Next([in] ULONG celt,
  436. [out, size_is(celt), length_is(*pceltFetched)] ISpObjectToken ** pelt,
  437. [out] ULONG *pceltFetched);
  438. HRESULT Skip([in] ULONG celt);
  439. HRESULT Reset(void);
  440. HRESULT Clone([out] IEnumSpObjectTokens **ppEnum);
  441. HRESULT Item([in] ULONG Index, [out] ISpObjectToken ** ppToken);
  442. HRESULT GetCount([out] ULONG* pCount);
  443. };
  444. //--- ISpObjectWithToken ----------------------------------------------------
  445. [
  446. object,
  447. uuid(5B559F40-E952-11D2-BB91-00C04F8EE6C0),
  448. helpstring("ISpObjectWithToken Interface"),
  449. pointer_default(unique),
  450. restricted
  451. ]
  452. interface ISpObjectWithToken : IUnknown
  453. {
  454. HRESULT SetObjectToken(ISpObjectToken * pToken);
  455. HRESULT GetObjectToken(ISpObjectToken ** ppToken);
  456. };
  457. //--- ISpResourceManager ----------------------------------------------------
  458. [
  459. object,
  460. uuid(93384E18-5014-43D5-ADBB-A78E055926BD),
  461. helpstring("ISpResourceManager Interface"),
  462. pointer_default(unique),
  463. restricted
  464. ]
  465. #ifdef _WIN32_WCE
  466. interface ISpResourceManager : IUnknown //IServiceProvider
  467. #else
  468. interface ISpResourceManager : IServiceProvider
  469. #endif // _WIN32_WCE
  470. {
  471. HRESULT SetObject(
  472. [in] REFGUID guidServiceId,
  473. [in] IUnknown *pUnkObject);
  474. HRESULT GetObject(
  475. [in] REFGUID guidServiceId,
  476. [in] REFCLSID ObjectCLSID,
  477. [in] REFIID ObjectIID,
  478. [in] BOOL fReleaseWhenLastExternalRefReleased,
  479. [out, iid_is(ObjectIID)] void** ppObject);
  480. };
  481. //--- ISpEventSource --------------------------------------------------------
  482. typedef [hidden] enum SPEVENTLPARAMTYPE
  483. {
  484. SPET_LPARAM_IS_UNDEFINED = 0,
  485. SPET_LPARAM_IS_TOKEN,
  486. SPET_LPARAM_IS_OBJECT,
  487. SPET_LPARAM_IS_POINTER,
  488. SPET_LPARAM_IS_STRING,
  489. } SPEVENTLPARAMTYPE;
  490. typedef [hidden] enum SPEVENTENUM
  491. {
  492. SPEI_UNDEFINED = 0,
  493. //--- TTS engine
  494. SPEI_START_INPUT_STREAM = 1,
  495. SPEI_END_INPUT_STREAM = 2,
  496. SPEI_VOICE_CHANGE = 3, // LPARAM_IS_TOKEN
  497. SPEI_TTS_BOOKMARK = 4, // LPARAM_IS_STRING
  498. SPEI_WORD_BOUNDARY = 5,
  499. SPEI_PHONEME = 6,
  500. SPEI_SENTENCE_BOUNDARY = 7,
  501. SPEI_VISEME = 8,
  502. SPEI_TTS_AUDIO_LEVEL = 9, // wParam contains current output audio level
  503. //--- Engine vendors use these reserved bits
  504. SPEI_TTS_PRIVATE = 15,
  505. SPEI_MIN_TTS = 1,
  506. SPEI_MAX_TTS = 15,
  507. //--- Speech Recognition
  508. SPEI_END_SR_STREAM = 34, // LPARAM contains HRESULT, WPARAM contains flags (SPESF_xxx)
  509. SPEI_SOUND_START = 35,
  510. SPEI_SOUND_END = 36,
  511. SPEI_PHRASE_START = 37,
  512. SPEI_RECOGNITION = 38,
  513. SPEI_HYPOTHESIS = 39,
  514. SPEI_SR_BOOKMARK = 40,
  515. SPEI_PROPERTY_NUM_CHANGE = 41, // LPARAM points to a string, WPARAM is the attrib value
  516. SPEI_PROPERTY_STRING_CHANGE= 42, // LPARAM pointer to buffer. Two concatinated null terminated strings.
  517. SPEI_FALSE_RECOGNITION = 43, // apparent speech with no valid recognition
  518. SPEI_INTERFERENCE = 44, // LPARAM is any combination of SPINTERFERENCE flags
  519. SPEI_REQUEST_UI = 45, // LPARAM is string.
  520. SPEI_RECO_STATE_CHANGE = 46, // wParam contains new reco state
  521. SPEI_ADAPTATION = 47, // we are now ready to accept the adaptation buffer
  522. SPEI_START_SR_STREAM = 48,
  523. SPEI_RECO_OTHER_CONTEXT = 49, // Phrase finished and recognized, but for other context
  524. SPEI_SR_AUDIO_LEVEL = 50, // wParam contains current input audio level
  525. //--- Engine vendors use these reserved bits
  526. SPEI_SR_PRIVATE = 52,
  527. SPEI_MIN_SR = 34,
  528. SPEI_MAX_SR = 52,
  529. SPEI_RESERVED1 = 30, // do not use
  530. SPEI_RESERVED2 = 33, // do not use
  531. SPEI_RESERVED3 = 63 // do not use
  532. } SPEVENTENUM;
  533. cpp_quote("#define SPFEI_FLAGCHECK ( (1ui64 << SPEI_RESERVED1) | (1ui64 << SPEI_RESERVED2) )")
  534. cpp_quote("#define SPFEI_ALL_TTS_EVENTS (0x000000000000FFFEui64 | SPFEI_FLAGCHECK)")
  535. cpp_quote("#define SPFEI_ALL_SR_EVENTS (0x001FFFFC00000000ui64 | SPFEI_FLAGCHECK)")
  536. cpp_quote("#define SPFEI_ALL_EVENTS 0xEFFFFFFFFFFFFFFFui64")
  537. // The SPFEI macro converts an SPEVENTENUM event value into a 64-bit value.
  538. // Multiple values can then be OR-ed together and passed to SetInterest.
  539. cpp_quote("#define SPFEI(SPEI_ord) ((1ui64 << SPEI_ord) | SPFEI_FLAGCHECK)")
  540. // SPEVENT is defined 2 ways, because the current version of MIDL does not allow enumerations
  541. // to be used as bit fields. So we define eEventId and elParamType as int bitfields for MIDL
  542. // and redefine them as their appropriate enumerations for C++
  543. cpp_quote("#if 0")
  544. typedef [restricted, hidden] struct SPEVENT
  545. {
  546. WORD eEventId; //SPEVENTENUM
  547. WORD elParamType; //SPEVENTLPARAMTYPE
  548. ULONG ulStreamNum; // Input stream number this event is associated with
  549. ULONGLONG ullAudioStreamOffset;
  550. WPARAM wParam;
  551. LPARAM lParam;
  552. } SPEVENT;
  553. typedef [restricted, hidden] struct SPSERIALIZEDEVENT
  554. {
  555. WORD eEventId; //SPEVENTENUM
  556. WORD elParamType; //SPEVENTLPARAMTYPE
  557. ULONG ulStreamNum; // Input stream number this event is associated with
  558. ULONGLONG ullAudioStreamOffset;
  559. ULONG SerializedwParam;
  560. LONG SerializedlParam;
  561. } SPSERIALIZEDEVENT;
  562. typedef [restricted, hidden] struct SPSERIALIZEDEVENT64
  563. {
  564. WORD eEventId; //SPEVENTENUM
  565. WORD elParamType; //SPEVENTLPARAMTYPE
  566. ULONG ulStreamNum; // Input stream number this event is associated with
  567. ULONGLONG ullAudioStreamOffset;
  568. ULONGLONG SerializedwParam;
  569. LONGLONG SerializedlParam;
  570. } SPSERIALIZEDEVENT64;
  571. cpp_quote("#else")
  572. cpp_quote("typedef struct SPEVENT")
  573. cpp_quote("{")
  574. cpp_quote(" SPEVENTENUM eEventId : 16;")
  575. cpp_quote(" SPEVENTLPARAMTYPE elParamType : 16;")
  576. cpp_quote(" ULONG ulStreamNum;")
  577. cpp_quote(" ULONGLONG ullAudioStreamOffset;")
  578. cpp_quote(" WPARAM wParam;")
  579. cpp_quote(" LPARAM lParam;")
  580. cpp_quote("} SPEVENT;")
  581. cpp_quote("typedef struct SPSERIALIZEDEVENT")
  582. cpp_quote("{")
  583. cpp_quote(" SPEVENTENUM eEventId : 16;")
  584. cpp_quote(" SPEVENTLPARAMTYPE elParamType : 16;")
  585. cpp_quote(" ULONG ulStreamNum;")
  586. cpp_quote(" ULONGLONG ullAudioStreamOffset;")
  587. cpp_quote(" ULONG SerializedwParam;")
  588. cpp_quote(" LONG SerializedlParam;")
  589. cpp_quote("} SPSERIALIZEDEVENT;")
  590. cpp_quote("typedef struct SPSERIALIZEDEVENT64")
  591. cpp_quote("{")
  592. cpp_quote(" SPEVENTENUM eEventId : 16;")
  593. cpp_quote(" SPEVENTLPARAMTYPE elParamType : 16;")
  594. cpp_quote(" ULONG ulStreamNum;")
  595. cpp_quote(" ULONGLONG ullAudioStreamOffset;")
  596. cpp_quote(" ULONGLONG SerializedwParam;")
  597. cpp_quote(" LONGLONG SerializedlParam;")
  598. cpp_quote("} SPSERIALIZEDEVENT64;")
  599. cpp_quote("#endif")
  600. //--- Types of interference
  601. typedef [hidden] enum SPINTERFERENCE
  602. {
  603. SPINTERFERENCE_NONE = 0,
  604. SPINTERFERENCE_NOISE,
  605. SPINTERFERENCE_NOSIGNAL,
  606. SPINTERFERENCE_TOOLOUD,
  607. SPINTERFERENCE_TOOQUIET,
  608. SPINTERFERENCE_TOOFAST,
  609. SPINTERFERENCE_TOOSLOW
  610. } SPINTERFERENCE;
  611. //--- Flags for END_SR_STREAM event (in WPARAM)
  612. typedef [hidden] enum SPENDSRSTREAMFLAGS
  613. {
  614. SPESF_NONE = 0,
  615. SPESF_STREAM_RELEASED = (1 << 0)
  616. } SPENDSRSTREAMFLAGS;
  617. //--- Viseme features
  618. typedef [hidden] enum SPVFEATURE
  619. {
  620. SPVFEATURE_STRESSED = (1L << 0),
  621. SPVFEATURE_EMPHASIS = (1L << 1)
  622. } SPVFEATURE;
  623. //--- Viseme event groups
  624. typedef [hidden] enum SPVISEMES
  625. {
  626. // English examples
  627. //------------------
  628. SP_VISEME_0 = 0, // Silence
  629. SP_VISEME_1, // AE, AX, AH
  630. SP_VISEME_2, // AA
  631. SP_VISEME_3, // AO
  632. SP_VISEME_4, // EY, EH, UH
  633. SP_VISEME_5, // ER
  634. SP_VISEME_6, // y, IY, IH, IX
  635. SP_VISEME_7, // w, UW
  636. SP_VISEME_8, // OW
  637. SP_VISEME_9, // AW
  638. SP_VISEME_10, // OY
  639. SP_VISEME_11, // AY
  640. SP_VISEME_12, // h
  641. SP_VISEME_13, // r
  642. SP_VISEME_14, // l
  643. SP_VISEME_15, // s, z
  644. SP_VISEME_16, // SH, CH, JH, ZH
  645. SP_VISEME_17, // TH, DH
  646. SP_VISEME_18, // f, v
  647. SP_VISEME_19, // d, t, n
  648. SP_VISEME_20, // k, g, NG
  649. SP_VISEME_21, // p, b, m
  650. } SPVISEMES;
  651. typedef [restricted, hidden] struct SPEVENTSOURCEINFO
  652. {
  653. ULONGLONG ullEventInterest;
  654. ULONGLONG ullQueuedInterest;
  655. ULONG ulCount;
  656. } SPEVENTSOURCEINFO;
  657. [
  658. object,
  659. uuid(BE7A9CCE-5F9E-11D2-960F-00C04F8EE628),
  660. helpstring("ISpEventSource Interface"),
  661. pointer_default(unique),
  662. local,
  663. restricted
  664. ]
  665. interface ISpEventSource : ISpNotifySource
  666. {
  667. // It is neccessary to use the SPFEI macro to convert the
  668. // SPEVENTENUM values into ULONGULONG values.
  669. HRESULT SetInterest(
  670. [in] ULONGLONG ullEventInterest,
  671. [in] ULONGLONG ullQueuedInterest);
  672. HRESULT GetEvents(
  673. [in] ULONG ulCount,
  674. [out, size_is(ulCount)] SPEVENT* pEventArray,
  675. [out] ULONG *pulFetched);
  676. HRESULT GetInfo([out] SPEVENTSOURCEINFO * pInfo);
  677. };
  678. //--- ISpEventSink ---------------------------------------------------------
  679. [
  680. object,
  681. uuid(BE7A9CC9-5F9E-11D2-960F-00C04F8EE628),
  682. helpstring("ISpEventSink Interface"),
  683. pointer_default(unique),
  684. local,
  685. restricted
  686. ]
  687. interface ISpEventSink : IUnknown
  688. {
  689. HRESULT AddEvents([in] const SPEVENT* pEventArray, [in] ULONG ulCount);
  690. HRESULT GetEventInterest([out] ULONGLONG * pullEventInterest);
  691. };
  692. //--- ISpStreamFormat -------------------------------------------------------
  693. [
  694. object,
  695. uuid(BED530BE-2606-4F4D-A1C0-54C5CDA5566F),
  696. helpstring("ISpStreamFormat Interface"),
  697. pointer_default(unique),
  698. restricted
  699. ]
  700. interface ISpStreamFormat : IStream
  701. {
  702. HRESULT GetFormat(GUID * pguidFormatId, WAVEFORMATEX ** ppCoMemWaveFormatEx);
  703. }
  704. typedef [hidden] enum SPFILEMODE
  705. {
  706. SPFM_OPEN_READONLY, // Open existing file, read-only
  707. SPFM_OPEN_READWRITE, // (Not supported for wav files) Open existing file, read-write
  708. SPFM_CREATE, // (Not supported for wav files) Open file if exists, else create if does not exist (opens read-write)
  709. SPFM_CREATE_ALWAYS, // Create file even if file exists. Destroys old file.
  710. SPFM_NUM_MODES // Used for limit checking
  711. } SPFILEMODE;
  712. //--- ISpStream -------------------------------------------------------------
  713. [
  714. object,
  715. uuid(12E3CCA9-7518-44C5-A5E7-BA5A79CB929E),
  716. helpstring("ISpStream Interface"),
  717. pointer_default(unique),
  718. restricted
  719. ]
  720. interface ISpStream : ISpStreamFormat
  721. {
  722. HRESULT SetBaseStream(IStream * pStream, REFGUID rguidFormat, const WAVEFORMATEX * pWaveFormatEx);
  723. HRESULT GetBaseStream(IStream ** ppStream);
  724. HRESULT BindToFile(const WCHAR * pszFileName, SPFILEMODE eMode,
  725. const GUID * pFormatId, const WAVEFORMATEX * pWaveFormatEx,
  726. ULONGLONG ullEventInterest);
  727. HRESULT Close();
  728. }
  729. //--- ISpStreamFormatConverter ----------------------------------------------
  730. [
  731. object,
  732. uuid(678A932C-EA71-4446-9B41-78FDA6280A29),
  733. helpstring("ISpStreamFormatConverter Interface"),
  734. pointer_default(unique),
  735. restricted
  736. ]
  737. interface ISpStreamFormatConverter : ISpStreamFormat
  738. {
  739. HRESULT SetBaseStream(
  740. [in] ISpStreamFormat * pStream,
  741. [in] BOOL fSetFormatToBaseStreamFormat, // If true, then format of format converter stream
  742. [in] BOOL fWriteToBaseStream ); // will be set to same format as bass stream
  743. // (set up as a pass-through). If pStream == NULL
  744. // and this is set to TRUE, then format of stream is reset
  745. HRESULT GetBaseStream([out] ISpStreamFormat **ppStream);
  746. HRESULT SetFormat([in] REFGUID rguidFormatIdOfConvertedStream, [in] const WAVEFORMATEX * pWaveFormatExOfConvertedStream);
  747. // Note: GetFormat method of ISpStreamFormat returns the format of the converted stream.
  748. HRESULT ResetSeekPosition();
  749. HRESULT ScaleConvertedToBaseOffset(
  750. [in] ULONGLONG ullOffsetConvertedStream,
  751. [out] ULONGLONG * pullOffsetBaseStream);
  752. HRESULT ScaleBaseToConvertedOffset(
  753. [in] ULONGLONG ullOffsetBaseStream,
  754. [out] ULONGLONG * pullOffsetConvertedStream);
  755. };
  756. //--- ISpAudio --------------------------------------------------------------
  757. typedef [hidden] enum _SPAUDIOSTATE
  758. {
  759. SPAS_CLOSED,
  760. SPAS_STOP,
  761. SPAS_PAUSE,
  762. SPAS_RUN
  763. } SPAUDIOSTATE;
  764. typedef [restricted, hidden] struct SPAUDIOSTATUS
  765. {
  766. long cbFreeBuffSpace;
  767. ULONG cbNonBlockingIO;
  768. SPAUDIOSTATE State;
  769. ULONGLONG CurSeekPos;
  770. ULONGLONG CurDevicePos;
  771. DWORD dwReserved1;
  772. DWORD dwReserved2;
  773. } SPAUDIOSTATUS;
  774. typedef [restricted, hidden] struct SPAUDIOBUFFERINFO
  775. {
  776. ULONG ulMsMinNotification;
  777. ULONG ulMsBufferSize;
  778. ULONG ulMsEventBias;
  779. } SPAUDIOBUFFERINFO;
  780. [
  781. object,
  782. uuid(C05C768F-FAE8-4EC2-8E07-338321C12452),
  783. helpstring("ISpAudio Interface"),
  784. pointer_default(unique),
  785. local,
  786. restricted
  787. ]
  788. interface ISpAudio : ISpStreamFormat
  789. {
  790. HRESULT SetState([in] SPAUDIOSTATE NewState, [in]ULONGLONG ullReserved );
  791. HRESULT SetFormat([in] REFGUID rguidFmtId, [in] const WAVEFORMATEX * pWaveFormatEx);
  792. HRESULT GetStatus([out] SPAUDIOSTATUS * pStatus);
  793. HRESULT SetBufferInfo([in] const SPAUDIOBUFFERINFO * pBuffInfo);
  794. HRESULT GetBufferInfo([out] SPAUDIOBUFFERINFO * pBuffInfo);
  795. HRESULT GetDefaultFormat([out] GUID * pFormatId, [out] WAVEFORMATEX ** ppCoMemWaveFormatEx);
  796. HANDLE EventHandle();
  797. HRESULT GetVolumeLevel([out] ULONG *pLevel);
  798. HRESULT SetVolumeLevel([in] ULONG Level);
  799. HRESULT GetBufferNotifySize([out] ULONG *pcbSize);
  800. HRESULT SetBufferNotifySize([in] ULONG cbSize);
  801. };
  802. //--- ISpMMSysAudio ---------------------------------------------------------
  803. [
  804. object,
  805. uuid(15806F6E-1D70-4B48-98E6-3B1A007509AB),
  806. helpstring("ISpMMSysAudio Interface"),
  807. pointer_default(unique),
  808. local,
  809. restricted
  810. ]
  811. interface ISpMMSysAudio : ISpAudio
  812. {
  813. HRESULT GetDeviceId([out] UINT * puDeviceId);
  814. HRESULT SetDeviceId([in] UINT uDeviceId);
  815. HRESULT GetMMHandle(void ** pHandle);
  816. HRESULT GetLineId([out] UINT *puLineId);
  817. HRESULT SetLineId([in] UINT uLineId);
  818. };
  819. //--- ISpTranscript ---------------------------------------------------------
  820. [
  821. object,
  822. uuid(10F63BCE-201A-11D3-AC70-00C04F8EE6C0),
  823. helpstring("ISpTranscript Interface"),
  824. pointer_default(unique),
  825. restricted
  826. ]
  827. interface ISpTranscript : IUnknown
  828. {
  829. HRESULT GetTranscript([out, string] WCHAR ** ppszTranscript);
  830. HRESULT AppendTranscript([in, string] const WCHAR * pszTranscript);
  831. };
  832. //--- Structures used by ISpPhrase interface --------------------------------
  833. typedef [hidden] enum SPDISPLYATTRIBUTES
  834. {
  835. SPAF_ONE_TRAILING_SPACE = 0x02,
  836. SPAF_TWO_TRAILING_SPACES = 0x04,
  837. SPAF_CONSUME_LEADING_SPACES = 0x08,
  838. SPAF_ALL = 0x0F
  839. } SPDISPLAYATTRIBUTES;
  840. typedef unsigned short SPPHONEID;
  841. typedef [restricted, hidden] struct SPPHRASEELEMENT
  842. {
  843. ULONG ulAudioTimeOffset;
  844. ULONG ulAudioSizeTime; // In 100ns units
  845. ULONG ulAudioStreamOffset;
  846. ULONG ulAudioSizeBytes;
  847. ULONG ulRetainedStreamOffset;
  848. ULONG ulRetainedSizeBytes;
  849. const WCHAR * pszDisplayText;
  850. const WCHAR * pszLexicalForm;
  851. const SPPHONEID * pszPronunciation;
  852. BYTE bDisplayAttributes;
  853. signed char RequiredConfidence;
  854. signed char ActualConfidence;
  855. BYTE Reserved;
  856. float SREngineConfidence;
  857. } SPPHRASEELEMENT;
  858. typedef [restricted, hidden] struct SPPHRASERULE SPPHRASERULE;
  859. [hidden] struct SPPHRASERULE
  860. {
  861. const WCHAR * pszName;
  862. ULONG ulId;
  863. ULONG ulFirstElement;
  864. ULONG ulCountOfElements;
  865. const SPPHRASERULE * pNextSibling;
  866. const SPPHRASERULE * pFirstChild;
  867. float SREngineConfidence;
  868. signed char Confidence;
  869. };
  870. typedef [restricted, hidden] struct SPPHRASEPROPERTY SPPHRASEPROPERTY;
  871. [hidden] struct SPPHRASEPROPERTY
  872. {
  873. const WCHAR * pszName;
  874. ULONG ulId;
  875. const WCHAR * pszValue;
  876. VARIANT vValue; // Will be VT_BOOL, VT_I4, VT_R4, VT_R8, or VT_BYREF (only for dynamic grammars)
  877. ULONG ulFirstElement;
  878. ULONG ulCountOfElements;
  879. const SPPHRASEPROPERTY* pNextSibling;
  880. const SPPHRASEPROPERTY* pFirstChild;
  881. float SREngineConfidence;
  882. signed char Confidence;
  883. };
  884. typedef [restricted, hidden] struct SPPHRASEREPLACEMENT
  885. {
  886. BYTE bDisplayAttributes;
  887. const WCHAR * pszReplacementText;
  888. ULONG ulFirstElement;
  889. ULONG ulCountOfElements;
  890. } SPPHRASEREPLACEMENT;
  891. typedef [restricted, hidden] struct SPPHRASE
  892. {
  893. ULONG cbSize; // Size of structure
  894. LANGID LangID;
  895. WORD wReserved;
  896. ULONGLONG ullGrammarID;
  897. ULONGLONG ftStartTime;
  898. ULONGLONG ullAudioStreamPosition;
  899. ULONG ulAudioSizeBytes;
  900. ULONG ulRetainedSizeBytes;
  901. ULONG ulAudioSizeTime; // In 100ns units
  902. SPPHRASERULE Rule;
  903. const SPPHRASEPROPERTY* pProperties;
  904. const SPPHRASEELEMENT * pElements;
  905. ULONG cReplacements;
  906. const SPPHRASEREPLACEMENT * pReplacements;
  907. GUID SREngineID;
  908. ULONG ulSREnginePrivateDataSize;
  909. const BYTE * pSREnginePrivateData;
  910. } SPPHRASE;
  911. //--- Serialized phrase
  912. typedef [restricted, hidden] struct SPSERIALIZEDPHRASE
  913. {
  914. ULONG ulSerializedSize; // Size of structure in bytes
  915. } SPSERIALIZEDPHRASE;
  916. typedef [hidden] enum SPVALUETYPE
  917. {
  918. SPDF_PROPERTY = 0x00000001,
  919. SPDF_REPLACEMENT = 0x00000002,
  920. SPDF_RULE = 0x00000004,
  921. SPDF_DISPLAYTEXT = 0x00000008,
  922. SPDF_LEXICALFORM = 0x00000010,
  923. SPDF_PRONUNCIATION = 0x00000020,
  924. SPDF_AUDIO = 0x00000040,
  925. SPDF_ALTERNATES = 0x00000080,
  926. SPDF_ALL = 0x000000FF
  927. } SPVALUETYPE;
  928. // Binary grammar public declaration
  929. typedef [hidden] struct SPBINARYGRAMMAR
  930. {
  931. ULONG ulTotalSerializedSize;
  932. } SPBINARYGRAMMAR;
  933. // Possible arguments for methods that take phrase element start and count
  934. typedef [hidden] enum SPPHRASERNG
  935. {
  936. SPPR_ALL_ELEMENTS = -1
  937. } SPPHRASERNG;
  938. cpp_quote("#define SP_GETWHOLEPHRASE SPPR_ALL_ELEMENTS")
  939. cpp_quote("#define SPRR_ALL_ELEMENTS SPPR_ALL_ELEMENTS")
  940. cpp_quote("#if 0")
  941. typedef void * SPSTATEHANDLE;
  942. cpp_quote("#else")
  943. cpp_quote("DECLARE_HANDLE(SPSTATEHANDLE);")
  944. cpp_quote("#endif")
  945. typedef [hidden] enum SPRECOEVENTFLAGS
  946. {
  947. SPREF_AutoPause = (1 << 0),
  948. SPREF_Emulated = (1 << 1)
  949. } SPRECOEVENTFLAGS;
  950. //--- ISpLexicon ------------------------------------------------------------
  951. typedef [hidden] enum SPPARTOFSPEECH
  952. {
  953. //--- SAPI5 public POS category values (bits 28-31)
  954. SPPS_NotOverriden = -1,
  955. SPPS_Unknown = 0,
  956. SPPS_Noun = 0x1000,
  957. SPPS_Verb = 0x2000,
  958. SPPS_Modifier = 0x3000,
  959. SPPS_Function = 0x4000,
  960. SPPS_Interjection = 0x5000
  961. } SPPARTOFSPEECH;
  962. typedef [hidden] enum SPLEXICONTYPE
  963. {
  964. eLEXTYPE_USER = (1L << 0),
  965. eLEXTYPE_APP = (1L << 1),
  966. eLEXTYPE_RESERVED1 = (1L << 2),
  967. eLEXTYPE_RESERVED2 = (1L << 3),
  968. eLEXTYPE_RESERVED3 = (1L << 4),
  969. eLEXTYPE_RESERVED4 = (1L << 5),
  970. eLEXTYPE_RESERVED5 = (1L << 6),
  971. eLEXTYPE_RESERVED6 = (1L << 7),
  972. eLEXTYPE_RESERVED7 = (1L << 8),
  973. eLEXTYPE_RESERVED8 = (1L << 9),
  974. eLEXTYPE_RESERVED9 = (1L << 10),
  975. eLEXTYPE_RESERVED10 = (1L << 11),
  976. eLEXTYPE_PRIVATE1 = (1L << 12),
  977. eLEXTYPE_PRIVATE2 = (1L << 13),
  978. eLEXTYPE_PRIVATE3 = (1L << 14),
  979. eLEXTYPE_PRIVATE4 = (1L << 15),
  980. eLEXTYPE_PRIVATE5 = (1L << 16),
  981. eLEXTYPE_PRIVATE6 = (1L << 17),
  982. eLEXTYPE_PRIVATE7 = (1L << 18),
  983. eLEXTYPE_PRIVATE8 = (1L << 19),
  984. eLEXTYPE_PRIVATE9 = (1L << 20),
  985. eLEXTYPE_PRIVATE10 = (1L << 21),
  986. eLEXTYPE_PRIVATE11 = (1L << 22),
  987. eLEXTYPE_PRIVATE12 = (1L << 23),
  988. eLEXTYPE_PRIVATE13 = (1L << 24),
  989. eLEXTYPE_PRIVATE14 = (1L << 25),
  990. eLEXTYPE_PRIVATE15 = (1L << 26),
  991. eLEXTYPE_PRIVATE16 = (1L << 27),
  992. eLEXTYPE_PRIVATE17 = (1L << 28),
  993. eLEXTYPE_PRIVATE18 = (1L << 29),
  994. eLEXTYPE_PRIVATE19 = (1L << 30),
  995. eLEXTYPE_PRIVATE20 = (1L << 31),
  996. } SPLEXICONTYPE;
  997. typedef [hidden] enum SPWORDTYPE
  998. {
  999. eWORDTYPE_ADDED = (1L << 0),
  1000. eWORDTYPE_DELETED = (1L << 1)
  1001. } SPWORDTYPE;
  1002. typedef [restricted, hidden] struct SPWORDPRONUNCIATION
  1003. {
  1004. struct SPWORDPRONUNCIATION * pNextWordPronunciation;
  1005. SPLEXICONTYPE eLexiconType;
  1006. LANGID LangID;
  1007. WORD wReserved;
  1008. SPPARTOFSPEECH ePartOfSpeech;
  1009. SPPHONEID szPronunciation[1];
  1010. } SPWORDPRONUNCIATION;
  1011. typedef [restricted, hidden] struct SPWORDPRONUNCIATIONLIST
  1012. {
  1013. ULONG ulSize;
  1014. BYTE * pvBuffer;
  1015. SPWORDPRONUNCIATION * pFirstWordPronunciation;
  1016. } SPWORDPRONUNCIATIONLIST;
  1017. typedef [restricted, hidden] struct SPWORD
  1018. {
  1019. struct SPWORD * pNextWord;
  1020. LANGID LangID;
  1021. WORD wReserved;
  1022. SPWORDTYPE eWordType;
  1023. WCHAR * pszWord;
  1024. SPWORDPRONUNCIATION * pFirstWordPronunciation;
  1025. } SPWORD;
  1026. typedef [restricted, hidden] struct SPWORDLIST
  1027. {
  1028. ULONG ulSize;
  1029. BYTE * pvBuffer;
  1030. SPWORD * pFirstWord;
  1031. } SPWORDLIST;
  1032. [
  1033. object,
  1034. uuid(DA41A7C2-5383-4DB2-916B-6C1719E3DB58),
  1035. helpstring("ISpLexicon Interface"),
  1036. pointer_default(unique),
  1037. restricted
  1038. ]
  1039. interface ISpLexicon : IUnknown
  1040. {
  1041. HRESULT GetPronunciations(
  1042. [in] const WCHAR * pszWord,
  1043. [in] LANGID LangID,
  1044. [in] DWORD dwFlags,
  1045. [in, out] SPWORDPRONUNCIATIONLIST * pWordPronunciationList
  1046. );
  1047. HRESULT AddPronunciation(
  1048. [in] const WCHAR * pszWord,
  1049. [in] LANGID LangID,
  1050. [in] SPPARTOFSPEECH ePartOfSpeech,
  1051. [in] const SPPHONEID * pszPronunciation
  1052. );
  1053. HRESULT RemovePronunciation(
  1054. [in] const WCHAR * pszWord,
  1055. [in] LANGID LangID,
  1056. [in] SPPARTOFSPEECH ePartOfSpeech,
  1057. [in] const SPPHONEID * pszPronunciation
  1058. );
  1059. HRESULT GetGeneration(DWORD *pdwGeneration);
  1060. HRESULT GetGenerationChange(
  1061. [in] DWORD dwFlags,
  1062. [in, out] DWORD *pdwGeneration,
  1063. [in, out] SPWORDLIST * pWordList
  1064. );
  1065. HRESULT GetWords(
  1066. [in] DWORD dwFlags,
  1067. [in, out] DWORD *pdwGeneration,
  1068. [in, out] DWORD * pdwCookie,
  1069. [in, out] SPWORDLIST *pWordList
  1070. );
  1071. };
  1072. [
  1073. object,
  1074. uuid(8565572F-C094-41CC-B56E-10BD9C3FF044),
  1075. helpstring("ISpContainerLexicon Interface"),
  1076. pointer_default(unique),
  1077. restricted
  1078. ]
  1079. interface ISpContainerLexicon : ISpLexicon
  1080. {
  1081. HRESULT AddLexicon([in] ISpLexicon *pAddLexicon, [in] DWORD dwFlags);
  1082. };
  1083. //--- ISpPhoneConverter -----------------------------------------------------
  1084. [
  1085. object,
  1086. uuid(8445C581-0CAC-4A38-ABFE-9B2CE2826455),
  1087. helpstring("ISpPhoneConverter Interface"),
  1088. pointer_default(unique),
  1089. restricted
  1090. ]
  1091. interface ISpPhoneConverter : ISpObjectWithToken
  1092. {
  1093. HRESULT PhoneToId([in] const WCHAR * pszPhone, [out] SPPHONEID * pId);
  1094. HRESULT IdToPhone([in] const SPPHONEID * pId, [out] WCHAR * pszPhone);
  1095. };
  1096. //--- ISpVoice --------------------------------------------------------------
  1097. // These structures maintain the absolute state of the voice relative to
  1098. // the voice's baseline XML state.
  1099. typedef [restricted, hidden] struct SPVPITCH
  1100. {
  1101. long MiddleAdj;
  1102. long RangeAdj;
  1103. } SPVPITCH;
  1104. typedef [hidden] enum SPVACTIONS
  1105. {
  1106. SPVA_Speak = 0,
  1107. SPVA_Silence,
  1108. SPVA_Pronounce,
  1109. SPVA_Bookmark,
  1110. SPVA_SpellOut,
  1111. SPVA_Section,
  1112. SPVA_ParseUnknownTag
  1113. } SPVACTIONS;
  1114. typedef [restricted, hidden] struct SPVCONTEXT
  1115. {
  1116. LPCWSTR pCategory;
  1117. LPCWSTR pBefore;
  1118. LPCWSTR pAfter;
  1119. } SPVCONTEXT;
  1120. typedef [restricted, hidden] struct SPVSTATE
  1121. {
  1122. //--- Action
  1123. SPVACTIONS eAction;
  1124. //--- Running state values
  1125. LANGID LangID;
  1126. WORD wReserved;
  1127. long EmphAdj;
  1128. long RateAdj;
  1129. ULONG Volume;
  1130. SPVPITCH PitchAdj;
  1131. ULONG SilenceMSecs;
  1132. SPPHONEID* pPhoneIds; // NULL terminated array of phone ids
  1133. SPPARTOFSPEECH ePartOfSpeech;
  1134. SPVCONTEXT Context;
  1135. } SPVSTATE;
  1136. typedef [hidden] enum SPRUNSTATE
  1137. {
  1138. SPRS_DONE = (1L << 0), // The voice is done rendering all queued phrases
  1139. SPRS_IS_SPEAKING = (1L << 1) // The SpVoice currently has the audio queue claimed
  1140. } SPRUNSTATE;
  1141. typedef [hidden] enum SPVLIMITS
  1142. {
  1143. SPMIN_VOLUME = 0,
  1144. SPMAX_VOLUME = 100,
  1145. SPMIN_RATE = -10,
  1146. SPMAX_RATE = 10
  1147. } SPVLIMITS;
  1148. typedef [hidden] enum SPVPRIORITY
  1149. {
  1150. SPVPRI_NORMAL = 0,
  1151. SPVPRI_ALERT = (1L << 0),
  1152. SPVPRI_OVER = (1L << 1)
  1153. } SPVPRIORITY;
  1154. typedef [restricted, hidden] struct SPVOICESTATUS
  1155. {
  1156. ULONG ulCurrentStream; // Current stream being rendered
  1157. ULONG ulLastStreamQueued; // Number of the last stream queued
  1158. HRESULT hrLastResult; // Result of last speak
  1159. DWORD dwRunningState; // SPRUNSTATE
  1160. ULONG ulInputWordPos; // Input position of current word being rendered
  1161. ULONG ulInputWordLen; // Length of current word being rendered
  1162. ULONG ulInputSentPos; // Input position of current sentence being rendered
  1163. ULONG ulInputSentLen; // Length of current sentence being rendered
  1164. LONG lBookmarkId; // Current bookmark converted to a long integer
  1165. SPPHONEID PhonemeId; // Current phoneme id
  1166. SPVISEMES VisemeId; // Current viseme
  1167. DWORD dwReserved1; // Reserved for future expansion
  1168. DWORD dwReserved2; // Reserved for future expansion
  1169. } SPVOICESTATUS;
  1170. typedef [hidden] enum SPEAKFLAGS
  1171. {
  1172. //--- SpVoice flags
  1173. SPF_DEFAULT = 0, // Synchronous, no purge, xml auto detect
  1174. SPF_ASYNC = (1L << 0), // Asynchronous call
  1175. SPF_PURGEBEFORESPEAK = (1L << 1), // Purge current data prior to speaking this
  1176. SPF_IS_FILENAME = (1L << 2), // The string passed to Speak() is a file name
  1177. SPF_IS_XML = (1L << 3), // The input text will be parsed for XML markup
  1178. SPF_IS_NOT_XML = (1L << 4), // The input text will not be parsed for XML markup
  1179. SPF_PERSIST_XML = (1L << 5), // Persists XML global state changes
  1180. //--- Normalizer flags
  1181. SPF_NLP_SPEAK_PUNC = (1L << 6), // The normalization processor should speak the punctuation
  1182. //--- Masks
  1183. SPF_NLP_MASK = (SPF_NLP_SPEAK_PUNC),
  1184. SPF_VOICE_MASK = (SPF_ASYNC|SPF_PURGEBEFORESPEAK|SPF_IS_FILENAME|SPF_IS_XML|SPF_IS_NOT_XML|SPF_NLP_MASK|SPF_PERSIST_XML),
  1185. SPF_UNUSED_FLAGS = ~(SPF_VOICE_MASK)
  1186. } SPEAKFLAGS;
  1187. [
  1188. object,
  1189. uuid(6C44DF74-72B9-4992-A1EC-EF996E0422D4),
  1190. helpstring("ISpVoice Interface"),
  1191. pointer_default(unique),
  1192. restricted
  1193. ]
  1194. interface ISpVoice : ISpEventSource
  1195. {
  1196. HRESULT SetOutput( [in] IUnknown * pUnkOutput, [in]BOOL fAllowFormatChanges );
  1197. HRESULT GetOutputObjectToken( [out] ISpObjectToken ** ppObjectToken );
  1198. HRESULT GetOutputStream( [out] ISpStreamFormat ** ppStream );
  1199. HRESULT Pause( void );
  1200. HRESULT Resume( void );
  1201. HRESULT SetVoice([in] ISpObjectToken *pToken);
  1202. HRESULT GetVoice([out] ISpObjectToken **ppToken);
  1203. HRESULT Speak(
  1204. [in, string] const WCHAR* pwcs,
  1205. [in] DWORD dwFlags,
  1206. [out] ULONG * pulStreamNumber);
  1207. HRESULT SpeakStream(
  1208. [in] IStream* pStream, // If not ISpStreamFormat supported then SPDFID_Text assumed
  1209. [in] DWORD dwFlags,
  1210. [out] ULONG * pulStreamNumber);
  1211. HRESULT GetStatus(
  1212. [out] SPVOICESTATUS *pStatus,
  1213. [out, string] WCHAR ** ppszLastBookmark);
  1214. HRESULT Skip( [in,string]WCHAR* pItemType, [in]long lNumItems, [out]ULONG* pulNumSkipped );
  1215. HRESULT SetPriority([in] SPVPRIORITY ePriority );
  1216. HRESULT GetPriority([out] SPVPRIORITY* pePriority );
  1217. HRESULT SetAlertBoundary( [in] SPEVENTENUM eBoundary );
  1218. HRESULT GetAlertBoundary( [out] SPEVENTENUM* peBoundary );
  1219. HRESULT SetRate([in] long RateAdjust );
  1220. HRESULT GetRate([out] long* pRateAdjust);
  1221. HRESULT SetVolume([in] USHORT usVolume);
  1222. HRESULT GetVolume([out] USHORT* pusVolume);
  1223. HRESULT WaitUntilDone([in] ULONG msTimeout);
  1224. HRESULT SetSyncSpeakTimeout([in] ULONG msTimeout);
  1225. HRESULT GetSyncSpeakTimeout([out] ULONG * pmsTimeout);
  1226. [local] HANDLE SpeakCompleteEvent();
  1227. [local] HRESULT IsUISupported(
  1228. [in] const WCHAR * pszTypeOfUI,
  1229. [in] void * pvExtraData,
  1230. [in] ULONG cbExtraData,
  1231. [out] BOOL *pfSupported);
  1232. [local] HRESULT DisplayUI(
  1233. [in] HWND hwndParent,
  1234. [in] const WCHAR * pszTitle,
  1235. [in] const WCHAR * pszTypeOfUI,
  1236. [in] void * pvExtraData,
  1237. [in] ULONG cbExtraData);
  1238. };
  1239. //--- ISpPhrase interface ---------------------------------------------------
  1240. [
  1241. object,
  1242. uuid(1A5C0354-B621-4b5a-8791-D306ED379E53),
  1243. local,
  1244. helpstring("ISpPhrase Interface"),
  1245. pointer_default(unique),
  1246. restricted
  1247. ]
  1248. interface ISpPhrase : IUnknown
  1249. {
  1250. HRESULT GetPhrase([out] SPPHRASE ** ppCoMemPhrase);
  1251. HRESULT GetSerializedPhrase([out] SPSERIALIZEDPHRASE ** ppCoMemPhrase);
  1252. HRESULT GetText([in] ULONG ulStart, [in] ULONG ulCount, [in] BOOL fUseTextReplacements,
  1253. [out] WCHAR ** ppszCoMemText, [out] BYTE * pbDisplayAttributes);
  1254. HRESULT Discard([in] DWORD dwValueTypes);
  1255. };
  1256. [
  1257. object,
  1258. uuid(8FCEBC98-4E49-4067-9C6C-D86A0E092E3D),
  1259. local,
  1260. helpstring("ISpPhraseAlt Interface"),
  1261. pointer_default(unique),
  1262. restricted
  1263. ]
  1264. interface ISpPhraseAlt : ISpPhrase
  1265. {
  1266. HRESULT GetAltInfo(ISpPhrase **ppParent, ULONG *pulStartElementInParent, ULONG *pcElementsInParent,
  1267. ULONG *pcElementsInAlt);
  1268. HRESULT Commit();
  1269. };
  1270. //--- ISpRecoResult ---------------------------------------------------------
  1271. typedef [restricted, hidden] struct SPRECORESULTTIMES
  1272. {
  1273. FILETIME ftStreamTime; // GetSystemTimeAsFileTime() at start of result
  1274. // UTC time as number of 100-nanosecond intervals
  1275. // since January 1, 1601
  1276. ULONGLONG ullLength; // length in 100ns units
  1277. DWORD dwTickCount; // GetTickCount() at start of result
  1278. // milliseconds that have elapsed since the
  1279. // system was started.
  1280. ULONGLONG ullStart; // 100ns units since start of stream
  1281. } SPRECORESULTTIMES;
  1282. typedef [hidden] struct SPSERIALIZEDRESULT
  1283. {
  1284. ULONG ulSerializedSize; // Count in bytes (including this ULONG) of the entire phrase
  1285. } SPSERIALIZEDRESULT;
  1286. [
  1287. object,
  1288. uuid(20B053BE-E235-43cd-9A2A-8D17A48B7842),
  1289. helpstring("ISpRecoResult Interface"),
  1290. pointer_default(unique),
  1291. local,
  1292. restricted
  1293. ]
  1294. interface ISpRecoResult : ISpPhrase
  1295. {
  1296. HRESULT GetResultTimes([out] SPRECORESULTTIMES *pTimes);
  1297. HRESULT GetAlternates(
  1298. [in] ULONG ulStartElement,
  1299. [in] ULONG cElements,
  1300. [in] ULONG ulRequestCount,
  1301. [out] ISpPhraseAlt **ppPhrases,
  1302. [out] ULONG *pcPhrasesReturned);
  1303. HRESULT GetAudio(
  1304. [in] ULONG ulStartElement,
  1305. [in] ULONG cElements,
  1306. [out] ISpStreamFormat **ppStream);
  1307. HRESULT SpeakAudio(
  1308. [in] ULONG ulStartElement,
  1309. [in] ULONG cElements,
  1310. [in] DWORD dwFlags,
  1311. [out] ULONG * pulStreamNumber);
  1312. HRESULT Serialize([out] SPSERIALIZEDRESULT ** ppCoMemSerializedResult);
  1313. HRESULT ScaleAudio([in] const GUID * pAudioFormatId, [in] const WAVEFORMATEX *pWaveFormatEx);
  1314. HRESULT GetRecoContext([out] ISpRecoContext ** ppRecoContext);
  1315. };
  1316. typedef [hidden] struct tagSPTEXTSELECTIONINFO
  1317. {
  1318. ULONG ulStartActiveOffset;
  1319. ULONG cchActiveChars;
  1320. ULONG ulStartSelection;
  1321. ULONG cchSelection;
  1322. } SPTEXTSELECTIONINFO;
  1323. typedef [hidden] enum SPWORDPRONOUNCEABLE
  1324. {
  1325. SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE = 0,
  1326. SPWP_UNKNOWN_WORD_PRONOUNCEABLE = 1,
  1327. SPWP_KNOWN_WORD_PRONOUNCEABLE = 2
  1328. } SPWORDPRONOUNCEABLE;
  1329. typedef [hidden] enum SPGRAMMARSTATE
  1330. {
  1331. SPGS_DISABLED = 0,
  1332. SPGS_ENABLED = 1,
  1333. SPGS_EXCLUSIVE = 3
  1334. } SPGRAMMARSTATE;
  1335. typedef [hidden] enum SPCONTEXTSTATE
  1336. {
  1337. SPCS_DISABLED = 0,
  1338. SPCS_ENABLED = 1,
  1339. } SPCONTEXTSTATE;
  1340. typedef [hidden] enum SPRULESTATE
  1341. {
  1342. SPRS_INACTIVE = 0,
  1343. SPRS_ACTIVE = 1,
  1344. SPRS_ACTIVE_WITH_AUTO_PAUSE = 3
  1345. } SPRULESTATE;
  1346. const ULONGLONG SP_STREAMPOS_ASAP = 0;
  1347. const ULONGLONG SP_STREAMPOS_REALTIME = -1;
  1348. // Special transition types used only by AddRuleTransition
  1349. cpp_quote("#define SPRULETRANS_TEXTBUFFER (SPSTATEHANDLE)(-1)")
  1350. cpp_quote("#define SPRULETRANS_WILDCARD (SPSTATEHANDLE)(-2)")
  1351. cpp_quote("#define SPRULETRANS_DICTATION (SPSTATEHANDLE)(-3)")
  1352. typedef [hidden] enum SPGRAMMARWORDTYPE
  1353. {
  1354. SPWT_DISPLAY,
  1355. SPWT_LEXICAL,
  1356. SPWT_PRONUNCIATION
  1357. } SPGRAMMARWORDTYPE;
  1358. typedef [hidden] struct tagSPPROPERTYINFO
  1359. {
  1360. const WCHAR * pszName;
  1361. ULONG ulId;
  1362. const WCHAR * pszValue;
  1363. VARIANT vValue; // Must be VT_BOOL, VT_I4, VT_R4, VT_R8, or VT_BYREF (only for dynamic grammars)
  1364. } SPPROPERTYINFO;
  1365. typedef [hidden] enum SPCFGRULEATTRIBUTES
  1366. {
  1367. SPRAF_TopLevel = (1 << 0),
  1368. SPRAF_Active = (1 << 1),
  1369. SPRAF_Export = (1 << 2),
  1370. SPRAF_Import = (1 << 3),
  1371. SPRAF_Interpreter = (1 << 4),
  1372. SPRAF_Dynamic = (1 << 5),
  1373. // The following flag is only valid at run-time as part of a rule state and
  1374. // is not valid to pass as part of a rule definition.
  1375. SPRAF_AutoPause = (1 << 16)
  1376. } SPCFGRULEATTRIBUTES;
  1377. [
  1378. object,
  1379. uuid(8137828F-591A-4A42-BE58-49EA7EBAAC68),
  1380. helpstring("ISpGrammarBuilder Interface"),
  1381. pointer_default(unique),
  1382. restricted,
  1383. local
  1384. ]
  1385. interface ISpGrammarBuilder : IUnknown
  1386. {
  1387. HRESULT ResetGrammar([in] LANGID NewLanguage);
  1388. HRESULT GetRule([in] const WCHAR * pszRuleName,
  1389. [in] DWORD dwRuleId,
  1390. [in] DWORD dwAttributes,
  1391. [in] BOOL fCreateIfNotExist,
  1392. [out] SPSTATEHANDLE * phInitialState);
  1393. HRESULT ClearRule(SPSTATEHANDLE hState);
  1394. HRESULT CreateNewState(
  1395. SPSTATEHANDLE hState,
  1396. SPSTATEHANDLE * phState);
  1397. HRESULT AddWordTransition(
  1398. SPSTATEHANDLE hFromState,
  1399. SPSTATEHANDLE hToState,
  1400. const WCHAR * psz, // If NULL then epsilon
  1401. const WCHAR * pszSeparators, // If NULL then psz points to a single word, else specifies valid separator characters
  1402. SPGRAMMARWORDTYPE eWordType,
  1403. float Weight,
  1404. const SPPROPERTYINFO * pPropInfo);
  1405. HRESULT AddRuleTransition(
  1406. SPSTATEHANDLE hFromState,
  1407. SPSTATEHANDLE hToState,
  1408. SPSTATEHANDLE hRule, // Must be the initial state of the rule
  1409. float Weight,
  1410. const SPPROPERTYINFO * pPropInfo);
  1411. HRESULT AddResource([in] SPSTATEHANDLE hRuleState, // Any state handle in a rule is OK
  1412. [in] const WCHAR * pszResourceName,
  1413. [in] const WCHAR * pszResourceValue);
  1414. HRESULT Commit(DWORD dwReserved);
  1415. };
  1416. // --- Options for Load methods on ISpRecoGrammar
  1417. typedef [hidden] enum SPLOADOPTIONS
  1418. {
  1419. SPLO_STATIC = 0,
  1420. SPLO_DYNAMIC = 1
  1421. } SPLOADOPTIONS;
  1422. //--- ISpRecoGrammar -------------------------------------------------------
  1423. [
  1424. object,
  1425. uuid(2177DB29-7F45-47D0-8554-067E91C80502),
  1426. helpstring("ISpRecoGrammar Interface"),
  1427. pointer_default(unique),
  1428. restricted,
  1429. local
  1430. ]
  1431. interface ISpRecoGrammar : ISpGrammarBuilder
  1432. {
  1433. HRESULT GetGrammarId([out] ULONGLONG * pullGrammarId);
  1434. HRESULT GetRecoContext([out] ISpRecoContext **ppRecoCtxt);
  1435. // Command and control interfaces
  1436. HRESULT LoadCmdFromFile([in, string] const WCHAR * pszFileName, [in] SPLOADOPTIONS Options);
  1437. HRESULT LoadCmdFromObject([in] REFCLSID rcid, [in, string] const WCHAR * pszGrammarName, [in] SPLOADOPTIONS Options);
  1438. HRESULT LoadCmdFromResource([in] HMODULE hModule,
  1439. [in, string] const WCHAR * pszResourceName,
  1440. [in, string] const WCHAR * pszResourceType,
  1441. [in] WORD wLanguage,
  1442. [in] SPLOADOPTIONS Options);
  1443. HRESULT LoadCmdFromMemory([in] const SPBINARYGRAMMAR * pGrammar, [in] SPLOADOPTIONS Options);
  1444. HRESULT LoadCmdFromProprietaryGrammar(
  1445. [in] REFGUID rguidParam,
  1446. [in, string] const WCHAR * pszStringParam,
  1447. [in] const void * pvDataPrarm,
  1448. [in] ULONG cbDataSize,
  1449. [in] SPLOADOPTIONS Options);
  1450. HRESULT SetRuleState([in, string] const WCHAR * pszName, void * pReserved,
  1451. [in] SPRULESTATE NewState);
  1452. HRESULT SetRuleIdState([in] ULONG ulRuleId, [in] SPRULESTATE NewState);
  1453. // Dictation / statistical language model
  1454. HRESULT LoadDictation([in, string] const WCHAR * pszTopicName, [in] SPLOADOPTIONS Options);
  1455. HRESULT UnloadDictation();
  1456. HRESULT SetDictationState([in] SPRULESTATE NewState);
  1457. // Word sequence buffer
  1458. HRESULT SetWordSequenceData([in] const WCHAR * pText, [in] ULONG cchText, [in] const SPTEXTSELECTIONINFO * pInfo);
  1459. HRESULT SetTextSelection([in] const SPTEXTSELECTIONINFO * pInfo);
  1460. HRESULT IsPronounceable([in, string] const WCHAR * pszWord, [out] SPWORDPRONOUNCEABLE *pWordPronounceable);
  1461. HRESULT SetGrammarState([in] SPGRAMMARSTATE eGrammarState);
  1462. HRESULT SaveCmd([in] IStream * pStream, [out, optional] WCHAR ** ppszCoMemErrorText);
  1463. HRESULT GetGrammarState([out] SPGRAMMARSTATE * peGrammarState);
  1464. };
  1465. //--- ISpRecoContext --------------------------------------------------------
  1466. typedef [restricted, hidden] struct SPRECOCONTEXTSTATUS
  1467. {
  1468. SPINTERFERENCE eInterference;
  1469. WCHAR szRequestTypeOfUI[255]; // If first byte null, there is no UI request
  1470. DWORD dwReserved1;
  1471. DWORD dwReserved2;
  1472. } SPRECOCONTEXTSTATUS;
  1473. typedef [hidden] enum SPBOOKMARKOPTIONS
  1474. {
  1475. SPBO_NONE = 0,
  1476. SPBO_PAUSE = 1
  1477. } SPBOOKMARKOPTIONS;
  1478. typedef [hidden] enum SPAUDIOOPTIONS
  1479. {
  1480. SPAO_NONE = 0,
  1481. SPAO_RETAIN_AUDIO = (1 << 0)
  1482. } SPAUDIOOPTIONS;
  1483. [
  1484. object,
  1485. uuid(F740A62F-7C15-489E-8234-940A33D9272D),
  1486. helpstring("ISpRecoContext Interface"),
  1487. pointer_default(unique),
  1488. local,
  1489. restricted
  1490. ]
  1491. interface ISpRecoContext : ISpEventSource
  1492. {
  1493. HRESULT GetRecognizer([out] ISpRecognizer ** ppRecognizer);
  1494. HRESULT CreateGrammar([in] ULONGLONG ullGrammarId, [out] ISpRecoGrammar ** ppGrammar);
  1495. HRESULT GetStatus([out] SPRECOCONTEXTSTATUS *pStatus);
  1496. HRESULT GetMaxAlternates([in] ULONG * pcAlternates);
  1497. HRESULT SetMaxAlternates([in] ULONG cAlternates);
  1498. HRESULT SetAudioOptions([in] SPAUDIOOPTIONS Options, [in] const GUID *pAudioFormatId, [in] const WAVEFORMATEX *pWaveFormatEx);
  1499. HRESULT GetAudioOptions([in] SPAUDIOOPTIONS * pOptions, [out] GUID *pAudioFormatId, [out] WAVEFORMATEX **ppCoMemWFEX);
  1500. HRESULT DeserializeResult(
  1501. [in] const SPSERIALIZEDRESULT * pSerializedResult,
  1502. [out] ISpRecoResult **ppResult);
  1503. HRESULT Bookmark([in] SPBOOKMARKOPTIONS Options, [in] ULONGLONG ullStreamPosition, [in] LPARAM lparamEvent);
  1504. HRESULT SetAdaptationData([in, string] const WCHAR *pAdaptationData, [in] const ULONG cch);
  1505. HRESULT Pause( DWORD dwReserved );
  1506. HRESULT Resume( DWORD dwReserved );
  1507. HRESULT SetVoice([in] ISpVoice *pVoice, [in] BOOL fAllowFormatChanges);
  1508. HRESULT GetVoice([out] ISpVoice **ppVoice);
  1509. HRESULT SetVoicePurgeEvent([in] ULONGLONG ullEventInterest);
  1510. HRESULT GetVoicePurgeEvent([out] ULONGLONG *pullEventInterest);
  1511. HRESULT SetContextState([in] SPCONTEXTSTATE eContextState);
  1512. HRESULT GetContextState([in] SPCONTEXTSTATE * peContextState);
  1513. };
  1514. //--- ISpProperties ------------------------------------------------------------
  1515. [
  1516. object,
  1517. uuid(5B4FB971-B115-4DE1-AD97-E482E3BF6EE4),
  1518. helpstring("ISpProperties Interface"),
  1519. pointer_default(unique),
  1520. local,
  1521. restricted
  1522. ]
  1523. interface ISpProperties : IUnknown
  1524. {
  1525. HRESULT SetPropertyNum( [in]const WCHAR* pName, [in]LONG lValue );
  1526. HRESULT GetPropertyNum( [in]const WCHAR* pName, [out]LONG* plValue );
  1527. HRESULT SetPropertyString( [in]const WCHAR* pName, [in]const WCHAR* pValue );
  1528. HRESULT GetPropertyString( [in]const WCHAR* pName, [out]WCHAR** ppCoMemValue );
  1529. };
  1530. const ULONG SP_MAX_LANGIDS = 20; // Engine can support up to 20 languages at once
  1531. //--- ISpRecognizer ---------------------------------------------------------
  1532. typedef [restricted, hidden] struct SPRECOGNIZERSTATUS
  1533. {
  1534. SPAUDIOSTATUS AudioStatus;
  1535. ULONGLONG ullRecognitionStreamPos;
  1536. ULONG ulStreamNumber;
  1537. ULONG ulNumActive;
  1538. CLSID clsidEngine;
  1539. ULONG cLangIDs;
  1540. LANGID aLangID[SP_MAX_LANGIDS];
  1541. DWORD dwReserved1;
  1542. DWORD dwReserved2;
  1543. } SPRECOGNIZERSTATUS;
  1544. typedef [hidden] enum SPWAVEFORMATTYPE
  1545. {
  1546. SPWF_INPUT, // WAVEFORMATEX of audio input source
  1547. SPWF_SRENGINE // WAVEFORMATEX of the audio received by the SR engine
  1548. } SPSTREAMFORMATTYPE;
  1549. typedef [hidden] enum SPRECOSTATE
  1550. {
  1551. SPRST_INACTIVE, // Audio deactivated
  1552. SPRST_ACTIVE, // Audio running only if one or more rules are active
  1553. SPRST_ACTIVE_ALWAYS, // Audio running regardless of rule state
  1554. SPRST_INACTIVE_WITH_PURGE, // State will be set to inactive, but all active audio purged
  1555. SPRST_NUM_STATES
  1556. } SPRECOSTATE;
  1557. [
  1558. object,
  1559. uuid(C2B5F241-DAA0-4507-9E16-5A1EAA2B7A5C),
  1560. helpstring("ISpRecognizer Interface"),
  1561. pointer_default(unique),
  1562. restricted
  1563. ]
  1564. interface ISpRecognizer : ISpProperties
  1565. {
  1566. HRESULT SetRecognizer([in] ISpObjectToken * pRecognizer);
  1567. HRESULT GetRecognizer([out] ISpObjectToken **ppRecognizer);
  1568. HRESULT SetInput([in] IUnknown * pUnkInput, [in] BOOL fAllowFormatChanges);
  1569. HRESULT GetInputObjectToken( [out] ISpObjectToken ** ppToken);
  1570. HRESULT GetInputStream( [out] ISpStreamFormat ** ppStream);
  1571. HRESULT CreateRecoContext([out] ISpRecoContext ** ppNewCtxt);
  1572. HRESULT GetRecoProfile([out] ISpObjectToken **ppToken);
  1573. HRESULT SetRecoProfile([in] ISpObjectToken *pToken);
  1574. HRESULT IsSharedInstance(void);
  1575. HRESULT GetRecoState([out] SPRECOSTATE *pState);
  1576. HRESULT SetRecoState([in] SPRECOSTATE NewState);
  1577. HRESULT GetStatus([out] SPRECOGNIZERSTATUS * pStatus);
  1578. HRESULT GetFormat([in] SPSTREAMFORMATTYPE WaveFormatType, [out] GUID *pFormatId, [out] WAVEFORMATEX **ppCoMemWFEX);
  1579. [local] HRESULT IsUISupported(
  1580. [in] const WCHAR * pszTypeOfUI,
  1581. [in] void * pvExtraData,
  1582. [in] ULONG cbExtraData,
  1583. [out] BOOL *pfSupported);
  1584. [local] HRESULT DisplayUI(
  1585. [in] HWND hwndParent,
  1586. [in] const WCHAR * pszTitle,
  1587. [in] const WCHAR * pszTypeOfUI,
  1588. [in] void * pvExtraData,
  1589. [in] ULONG cbExtraData);
  1590. HRESULT EmulateRecognition([in] ISpPhrase *pPhrase);
  1591. };
  1592. //
  1593. //=== CoClass definitions =====================================================
  1594. //
  1595. [
  1596. helpstring("Microsoft Speech Object Library"),
  1597. uuid(C866CA3A-32F7-11D2-9602-00C04F8EE628),
  1598. version(5.0)
  1599. ]
  1600. library SpeechLib
  1601. {
  1602. importlib("stdole32.tlb");
  1603. importlib("stdole2.tlb");
  1604. #include "sapiaut.idl"
  1605. //--- SpNotifyTranslator ------------------------------------------------
  1606. [
  1607. uuid(E2AE5372-5D40-11D2-960E-00C04F8EE628),
  1608. helpstring("SpNotify"),
  1609. restricted,
  1610. hidden
  1611. ]
  1612. coclass SpNotifyTranslator
  1613. {
  1614. interface ISpNotifyTranslator;
  1615. }
  1616. //--- SpObjectTokenCategory ---------------------------------------------
  1617. [
  1618. uuid(A910187F-0C7A-45AC-92CC-59EDAFB77B53),
  1619. helpstring("SpObjectTokenCategory Class"),
  1620. ]
  1621. coclass SpObjectTokenCategory
  1622. {
  1623. [default] interface ISpeechObjectTokenCategory;
  1624. interface ISpObjectTokenCategory;
  1625. }
  1626. //--- SpObjectToken ---------------------------------------------
  1627. [
  1628. uuid(EF411752-3736-4CB4-9C8C-8EF4CCB58EFE),
  1629. helpstring("SpObjectToken Class")
  1630. ]
  1631. coclass SpObjectToken
  1632. {
  1633. [default] interface ISpeechObjectToken;
  1634. interface ISpObjectToken;
  1635. }
  1636. //--- SpResourceManager -------------------------------------------------
  1637. [
  1638. uuid(96749373-3391-11D2-9EE3-00C04F797396),
  1639. helpstring("SpResourceManger"),
  1640. restricted,
  1641. hidden
  1642. ]
  1643. coclass SpResourceManager
  1644. {
  1645. [default] interface ISpResourceManager;
  1646. };
  1647. //--- SpStreamFormatConverter -------------------------------------------
  1648. [
  1649. uuid(7013943A-E2EC-11D2-A086-00C04F8EF9B5),
  1650. helpstring("FormatConverter Class"),
  1651. restricted,
  1652. hidden
  1653. ]
  1654. coclass SpStreamFormatConverter
  1655. {
  1656. [default] interface ISpStreamFormatConverter;
  1657. };
  1658. //--- SpMMAudioEnum -----------------------------------------------------
  1659. [
  1660. uuid(AB1890A0-E91F-11D2-BB91-00C04F8EE6C0),
  1661. helpstring("SpMMAudioEnum Class"),
  1662. restricted,
  1663. hidden
  1664. ]
  1665. coclass SpMMAudioEnum
  1666. {
  1667. interface IEnumSpObjectTokens;
  1668. };
  1669. //--- SpMMAudioIn -------------------------------------------------------
  1670. [
  1671. uuid(CF3D2E50-53F2-11D2-960C-00C04F8EE628),
  1672. helpstring("SpMMAudioIn Class")
  1673. ]
  1674. coclass SpMMAudioIn
  1675. {
  1676. [default] interface ISpeechMMSysAudio;
  1677. interface ISpEventSource;
  1678. interface ISpEventSink;
  1679. interface ISpObjectWithToken;
  1680. interface ISpMMSysAudio;
  1681. };
  1682. //--- SpMMAudioOut ------------------------------------------------------
  1683. [
  1684. uuid(A8C680EB-3D32-11D2-9EE7-00C04F797396),
  1685. helpstring("SpMMAudioOut Class")
  1686. ]
  1687. coclass SpMMAudioOut
  1688. {
  1689. [default] interface ISpeechMMSysAudio;
  1690. interface ISpEventSource;
  1691. interface ISpEventSink;
  1692. interface ISpObjectWithToken;
  1693. interface ISpMMSysAudio;
  1694. };
  1695. //--- SpRecPlayAudio -------------------------------------------------
  1696. [
  1697. uuid(FEE225FC-7AFD-45E9-95D0-5A318079D911),
  1698. helpstring("SpRecPlayAudio Class"),
  1699. restricted,
  1700. hidden
  1701. ]
  1702. coclass SpRecPlayAudio
  1703. {
  1704. interface ISpObjectWithToken;
  1705. interface ISpAudio;
  1706. };
  1707. //--- SpStream ----------------------------------------------------------
  1708. [
  1709. uuid(715D9C59-4442-11D2-9605-00C04F8EE628),
  1710. helpstring("SpStream Class"),
  1711. restricted,
  1712. hidden
  1713. ]
  1714. coclass SpStream
  1715. {
  1716. interface ISpStream;
  1717. };
  1718. //--- SpVoice -----------------------------------------------------------
  1719. [
  1720. uuid(96749377-3391-11D2-9EE3-00C04F797396),
  1721. helpstring("SpVoice Class")
  1722. ]
  1723. coclass SpVoice
  1724. {
  1725. [default] interface ISpeechVoice;
  1726. interface ISpVoice;
  1727. [default, source] dispinterface _ISpeechVoiceEvents;
  1728. };
  1729. //--- SpSharedRecoContext -----------------------------------------------
  1730. [
  1731. uuid(47206204-5ECA-11D2-960F-00C04F8EE628),
  1732. helpstring("SpSharedRecoContext Class")
  1733. ]
  1734. coclass SpSharedRecoContext
  1735. {
  1736. [default] interface ISpeechRecoContext;
  1737. interface ISpRecoContext;
  1738. [default, source] dispinterface _ISpeechRecoContextEvents;
  1739. };
  1740. //--- SpInprocRecognizer ------------------------------------------------
  1741. [
  1742. uuid(41B89B6B-9399-11D2-9623-00C04F8EE628),
  1743. helpstring("SpInprocRecognizer Class")
  1744. ]
  1745. coclass SpInprocRecognizer
  1746. {
  1747. [default] interface ISpeechRecognizer;
  1748. interface ISpRecognizer;
  1749. };
  1750. //--- SpSharedRecognizer ----------------------------------------------
  1751. [
  1752. uuid(3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F),
  1753. helpstring("SpSharedRecognizer Class")
  1754. ]
  1755. coclass SpSharedRecognizer
  1756. {
  1757. [default] interface ISpeechRecognizer;
  1758. interface ISpRecognizer;
  1759. };
  1760. //--- SpLexicon ----------------------------------------------------------
  1761. [
  1762. uuid(0655E396-25D0-11D3-9C26-00C04F8EF87C),
  1763. helpstring("SpLexicon Class")
  1764. ]
  1765. coclass SpLexicon
  1766. {
  1767. [default] interface ISpeechLexicon;
  1768. interface ISpLexicon;
  1769. };
  1770. //--- SpUnCompressedLexicon ---------------------------------------------------
  1771. [
  1772. uuid(C9E37C15-DF92-4727-85D6-72E5EEB6995A),
  1773. helpstring("SpUnCompressedLexicon Class")
  1774. ]
  1775. coclass SpUnCompressedLexicon
  1776. {
  1777. [default] interface ISpeechLexicon;
  1778. interface ISpLexicon;
  1779. interface ISpObjectWithToken;
  1780. };
  1781. //--- SpCompressedLexicon ---------------------------------------------------
  1782. [
  1783. uuid(90903716-2F42-11D3-9C26-00C04F8EF87C),
  1784. helpstring("SpCompressedLexicon Class"),
  1785. restricted,
  1786. hidden
  1787. ]
  1788. coclass SpCompressedLexicon
  1789. {
  1790. [default] interface ISpLexicon;
  1791. interface ISpObjectWithToken;
  1792. };
  1793. //--- SpPhoneConverter ------------------------------------------------
  1794. [
  1795. uuid(9185F743-1143-4C28-86B5-BFF14F20E5C8),
  1796. helpstring("SpPhoneConverter Class")
  1797. ]
  1798. coclass SpPhoneConverter
  1799. {
  1800. [default] interface ISpeechPhoneConverter;
  1801. interface ISpPhoneConverter;
  1802. };
  1803. //--- SpNullPhoneConverter ------------------------------------------------
  1804. [
  1805. uuid(455F24E9-7396-4A16-9715-7C0FDBE3EFE3),
  1806. helpstring("SpNullPhoneConverter Class"),
  1807. restricted,
  1808. hidden
  1809. ]
  1810. coclass SpNullPhoneConverter
  1811. {
  1812. [default] interface ISpPhoneConverter;
  1813. };
  1814. #ifdef SAPI_AUTOMATION
  1815. //--- SpTextSelectionInformation ------------------------------------------------
  1816. [
  1817. uuid(0F92030A-CBFD-4AB8-A164-FF5985547FF6),
  1818. helpstring("SpTextSelectionInformation Class"),
  1819. ]
  1820. coclass SpTextSelectionInformation
  1821. {
  1822. [default] interface ISpeechTextSelectionInformation;
  1823. };
  1824. //--- SpPhraseInfoBuilder ------------------------------------------------
  1825. [
  1826. uuid(C23FC28D-C55F-4720-8B32-91F73C2BD5D1),
  1827. helpstring("SpPhraseInfoBuilder Class"),
  1828. ]
  1829. coclass SpPhraseInfoBuilder
  1830. {
  1831. [default] interface ISpeechPhraseInfoBuilder;
  1832. };
  1833. //--- SpAudioFormat ------------------------------------------------
  1834. [
  1835. uuid(9EF96870-E160-4792-820D-48CF0649E4EC),
  1836. helpstring("SpAudioFormat Class"),
  1837. ]
  1838. coclass SpAudioFormat
  1839. {
  1840. [default] interface ISpeechAudioFormat;
  1841. };
  1842. //--- SpWaveFormatEx ------------------------------------------------
  1843. [
  1844. uuid(C79A574C-63BE-44b9-801F-283F87F898BE),
  1845. helpstring("SpWaveFormatEx Class"),
  1846. ]
  1847. coclass SpWaveFormatEx
  1848. {
  1849. [default] interface ISpeechWaveFormatEx;
  1850. };
  1851. //--- SpInProcRecoContext -----------------------------------------------
  1852. [
  1853. uuid(73AD6842-ACE0-45E8-A4DD-8795881A2C2A),
  1854. helpstring("SpInProcRecoContext Class")
  1855. ]
  1856. coclass SpInProcRecoContext
  1857. {
  1858. [default] interface ISpeechRecoContext;
  1859. interface ISpRecoContext;
  1860. [default, source] dispinterface _ISpeechRecoContextEvents;
  1861. };
  1862. //--- SpCustomStream ------------------------------------------------
  1863. [
  1864. uuid(8DBEF13F-1948-4aa8-8CF0-048EEBED95D8),
  1865. helpstring("SpCustomStream Class"),
  1866. ]
  1867. coclass SpCustomStream
  1868. {
  1869. [default] interface ISpeechCustomStream;
  1870. interface ISpStream;
  1871. };
  1872. //--- SpFileStream ------------------------------------------------
  1873. [
  1874. uuid(947812B3-2AE1-4644-BA86-9E90DED7EC91),
  1875. helpstring("SpFileStream Class"),
  1876. ]
  1877. coclass SpFileStream
  1878. {
  1879. [default] interface ISpeechFileStream;
  1880. interface ISpStream;
  1881. };
  1882. //--- SpMemoryStream ------------------------------------------------
  1883. [
  1884. uuid(5FB7EF7D-DFF4-468a-B6B7-2FCBD188F994),
  1885. helpstring("SpMemoryStream Class"),
  1886. ]
  1887. coclass SpMemoryStream
  1888. {
  1889. [default] interface ISpeechMemoryStream;
  1890. interface ISpStream;
  1891. };
  1892. #endif // SAPI_AUTOMATION
  1893. }