/*
 * Copyright (C) 2019 Alistair Leslie-Hughes
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
#if 0
#pragma makedep install
#endif

import "oaidl.idl";
import "ocidl.idl";

interface ISpeechAudioFormat;
interface ISpeechGrammarRule;
interface ISpeechGrammarRuleState;
interface ISpeechObjectTokens;
interface ISpeechPhraseProperties;
interface ISpeechPhraseRule;
interface ISpeechRecognizer;
interface ISpeechRecoContext;
interface ISpeechRecoGrammar;
interface ISpeechRecoResult;

typedef long SpeechLanguageId;

typedef enum SpeechLoadOption
{
    SLOStatic  = SPLO_STATIC,
    SLODynamic = SPLO_DYNAMIC
} SpeechLoadOption;

typedef enum SpeechRuleState
{
    SGDSInactive            = SPRS_INACTIVE,
    SGDSActive              = SPRS_ACTIVE,
    SGDSActiveWithAutoPause = SPRS_ACTIVE_WITH_AUTO_PAUSE,
    SGDSActiveUserDelimited = SPRS_ACTIVE_USER_DELIMITED
} SpeechRuleState;

typedef enum SpeechTokenShellFolder
{
    STSF_AppData         = 0x001a,
    STSF_LocalAppData    = 0x001c,
    STSF_CommonAppData   = 0x0023,
    STSF_FlagCreate      = 0x8000
} SpeechTokenShellFolder;

typedef enum SpeechEngineConfidence
{
    SECLowConfidence    = -1,
    SECNormalConfidence =  0,
    SECHighConfidence   =  1
} SpeechEngineConfidence;

typedef enum SpeechAudioState
{
    SASClosed = SPAS_CLOSED,
    SASStop   = SPAS_STOP,
    SASPause  = SPAS_PAUSE,
    SASRun    = SPAS_RUN
} SpeechAudioState;

typedef enum SpeechRunState
{
    SRSEDone       = SPRS_DONE,
    SRSEIsSpeaking = SPRS_IS_SPEAKING
} SpeechRunState;

typedef enum SpeechDiscardType
{
    SDTProperty      = SPDF_PROPERTY,
    SDTReplacement   = SPDF_REPLACEMENT,
    SDTRule          = SPDF_RULE,
    SDTDisplayText   = SPDF_DISPLAYTEXT,
    SDTLexicalForm   = SPDF_LEXICALFORM,
    SDTPronunciation = SPDF_PRONUNCIATION,
    SDTAudio         = SPDF_AUDIO,
    SDTAlternates    = SPDF_ALTERNATES,
    SDTAll           = SPDF_ALL
} SpeechDiscardType;

typedef enum SpeechRecognizerState
{
    SRSInactive          = SPRST_INACTIVE,
    SRSActive            = SPRST_ACTIVE,
    SRSActiveAlways      = SPRST_ACTIVE_ALWAYS,
    SRSInactiveWithPurge = SPRST_INACTIVE_WITH_PURGE,
} SpeechRecognizerState;

typedef enum SpeechDisplayAttributes
{
    SDA_No_Trailing_Space      = 0,
    SDA_One_Trailing_Space     = SPAF_ONE_TRAILING_SPACE,
    SDA_Two_Trailing_Spaces    = SPAF_TWO_TRAILING_SPACES,
    SDA_Consume_Leading_Spaces = SPAF_CONSUME_LEADING_SPACES
} SpeechDisplayAttributes;

typedef enum SpeechFormatType
{
    SFTInput    = SPWF_INPUT,
    SFTSREngine = SPWF_SRENGINE
} SpeechFormatType;

typedef enum SpeechGrammarState
{
    SGSEnabled   = SPGS_ENABLED,
    SGSDisabled  = SPGS_DISABLED,
    SGSExclusive = SPGS_EXCLUSIVE,
} SpeechGrammarState;

typedef enum SpeechRuleAttributes
{
    SRATopLevel        = SPRAF_TopLevel,
    SRADefaultToActive = SPRAF_Active,
    SRAExport          = SPRAF_Export,
    SRAImport          = SPRAF_Import,
    SRAInterpreter     = SPRAF_Interpreter,
    SRADynamic         = SPRAF_Dynamic,
    SRARoot            = SPRAF_Root
} SpeechRuleAttributes;

typedef enum SpeechWordPronounceable
{
    SWPUnknownWordUnpronounceable = SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE,
    SWPUnknownWordPronounceable   = SPWP_UNKNOWN_WORD_PRONOUNCEABLE,
    SWPKnownWordPronounceable     = SPWP_KNOWN_WORD_PRONOUNCEABLE
} SpeechWordPronounceable;

typedef enum SpeechSpecialTransitionType
{
    SSTTWildcard = 1,
    SSTTDictation,
    SSTTTextBuffer
} SpeechSpecialTransitionType;

typedef [hidden] enum DISPID_SpeechRecoContext
{
    DISPID_SRCRecognizer                         = 1,
    DISPID_SRCAudioInInterferenceStatus,
    DISPID_SRCRequestedUIType,
    DISPID_SRCVoice,
    DISPID_SRAllowVoiceFormatMatchingOnNextSet,
    DISPID_SRCVoicePurgeEvent,
    DISPID_SRCEventInterests,
    DISPID_SRCCmdMaxAlternates,
    DISPID_SRCState,
    DISPID_SRCRetainedAudio,
    DISPID_SRCRetainedAudioFormat,
    DISPID_SRCPause,
    DISPID_SRCResume,
    DISPID_SRCCreateGrammar,
    DISPID_SRCCreateResultFromMemory,
    DISPID_SRCBookmark,
    DISPID_SRCSetAdaptationData
} DISPID_SpeechRecoContext;

typedef [hidden] enum DISPID_SpeechDataKey
{
    DISPID_SDKSetBinaryValue = 1,
    DISPID_SDKGetBinaryValue,
    DISPID_SDKSetStringValue,
    DISPID_SDKGetStringValue,
    DISPID_SDKSetLongValue,
    DISPID_SDKGetlongValue,
    DISPID_SDKOpenKey,
    DISPID_SDKCreateKey,
    DISPID_SDKDeleteKey,
    DISPID_SDKDeleteValue,
    DISPID_SDKEnumKeys,
    DISPID_SDKEnumValues
} DISPID_SpeechDataKey;

typedef [hidden] enum DISPIDSPRG
{
    DISPID_SRGId = 1,
    DISPID_SRGRecoContext,
    DISPID_SRGState,
    DISPID_SRGRules,
    DISPID_SRGReset,
    DISPID_SRGCommit,
    DISPID_SRGCmdLoadFromFile,
    DISPID_SRGCmdLoadFromObject,
    DISPID_SRGCmdLoadFromResource,
    DISPID_SRGCmdLoadFromMemory,
    DISPID_SRGCmdLoadFromProprietaryGrammar,
    DISPID_SRGCmdSetRuleState,
    DISPID_SRGCmdSetRuleIdState,
    DISPID_SRGDictationLoad,
    DISPID_SRGDictationUnload,
    DISPID_SRGDictationSetState,
    DISPID_SRGSetWordSequenceData,
    DISPID_SRGSetTextSelection,
    DISPID_SRGIsPronounceable
} DISPIDSPRG;

typedef enum SpeechInterference
{
    SINone     = SPINTERFERENCE_NONE,
    SINoise    = SPINTERFERENCE_NOISE,
    SINoSignal = SPINTERFERENCE_NOSIGNAL,
    SITooLoud  = SPINTERFERENCE_TOOLOUD,
    SITooQuiet = SPINTERFERENCE_TOOQUIET,
    SITooFast  = SPINTERFERENCE_TOOFAST,
    SITooSlow  = SPINTERFERENCE_TOOSLOW
} SpeechInterference;

typedef enum SpeechVoiceEvents
{
    SVEStartInputStream = (1L << 1),
    SVEEndInputStream   = (1L << 2),
    SVEVoiceChange      = (1L << 3),
    SVEBookmark         = (1L << 4),
    SVEWordBoundary     = (1L << 5),
    SVEPhoneme          = (1L << 6),
    SVESentenceBoundary = (1L << 7),
    SVEViseme           = (1L << 8),
    SVEAudioLevel       = (1L << 9),
    SVEPrivate          = (1L << 15),
    SVEAllEvents        = 0x083FE
} SpeechVoiceEvents;

typedef enum SpeechVoiceSpeakFlags
{
    SVSFDefault          = SPF_DEFAULT,
    SVSFlagsAsync        = SPF_ASYNC,
    SVSFPurgeBeforeSpeak = SPF_PURGEBEFORESPEAK,
    SVSFIsFilename       = SPF_IS_FILENAME,
    SVSFIsXML            = SPF_IS_XML,
    SVSFIsNotXML         = SPF_IS_NOT_XML,
    SVSFPersistXML       = SPF_PERSIST_XML,
    SVSFNLPSpeakPunc     = SPF_NLP_SPEAK_PUNC,
    SVSFParseSapi        = SPF_PARSE_SAPI,
    SVSFParseSsml        = SPF_PARSE_SSML,
    SVSFParseAutodetect  = SPF_PARSE_AUTODETECT,
    SVSFNLPMask          = SPF_NLP_MASK,
    SVSFParseMask        = SPF_PARSE_MASK,
    SVSFVoiceMask        = SPF_VOICE_MASK,
    SVSFUnusedFlags      = SPF_UNUSED_FLAGS,
} SpeechVoiceSpeakFlags;

typedef enum SpeechGrammarWordType
{
    SGDisplay               = SPWT_DISPLAY,
    SGLexical               = SPWT_LEXICAL,
    SGPronounciation        = SPWT_PRONUNCIATION,
    SGLexicalNoSpecialChars = SPWT_LEXICAL_NO_SPECIAL_CHARS
} SpeechGrammarWordType;

typedef enum SpeechRecoEvents
{
    SREStreamEnd            = (1L << 0),
    SRESoundStart           = (1L << 1),
    SRESoundEnd             = (1L << 2),
    SREPhraseStart          = (1L << 3),
    SRERecognition          = (1L << 4),
    SREHypothesis           = (1L << 5),
    SREBookmark             = (1L << 6),
    SREPropertyNumChange    = (1L << 7),
    SREPropertyStringChange = (1L << 8),
    SREFalseRecognition     = (1L << 9),
    SREInterference         = (1L << 10),
    SRERequestUI            = (1L << 11),
    SREStateChange          = (1L << 12),
    SREAdaptation           = (1L << 13),
    SREStreamStart          = (1L << 14),
    SRERecoOtherContext     = (1L << 15),
    SREAudioLevel           = (1L << 16),
    SREPrivate              = (1L << 18),
    SREAllEvents            = 0x5FFFF
} SpeechRecoEvents;

typedef enum SpeechRecoContextState
{
    SRCS_Disabled = SPCS_DISABLED,
    SRCS_Enabled  = SPCS_ENABLED
} SpeechRecoContextState;

typedef enum SpeechRetainedAudioOptions
{
    SRAONone        = SPAO_NONE,
    SRAORetainAudio = SPAO_RETAIN_AUDIO
} SpeechRetainedAudioOptions;

typedef enum SpeechVoicePriority
{
    SVPNormal = SPVPRI_NORMAL,
    SVPAlert  = SPVPRI_ALERT,
    SVPOver   = SPVPRI_OVER
} SpeechVoicePriority;

[
    object,
    uuid(ce17c09b-4efa-44d5-a4c9-59d9585ab0cd),
    dual,
    pointer_default(unique)
]
interface ISpeechDataKey : IDispatch
{
    [id(DISPID_SDKSetBinaryValue)]
    HRESULT SetBinaryValue([in] const BSTR name, [in] VARIANT value);

    [id(DISPID_SDKGetBinaryValue)]
    HRESULT GetBinaryValue([in] const BSTR name, [out,retval] VARIANT *value);

    [id(DISPID_SDKSetStringValue)]
    HRESULT SetStringValue([in] const BSTR name, [in]const BSTR value);

    [id(DISPID_SDKGetStringValue)]
    HRESULT GetStringValue([in] const BSTR name, [out,retval] BSTR* value);

    [id(DISPID_SDKSetLongValue)]
    HRESULT SetLongValue([in] const BSTR name, [in] long value);

    [id(DISPID_SDKGetlongValue)]
    HRESULT GetLongValue([in] const BSTR name, [out,retval] long *value);

    [id(DISPID_SDKOpenKey)]
    HRESULT OpenKey( [in] const BSTR name, [out,retval] ISpeechDataKey **key);

    [id(DISPID_SDKCreateKey)]
    HRESULT CreateKey([in] const BSTR name, [out,retval] ISpeechDataKey **key);

    [id(DISPID_SDKDeleteKey)]
    HRESULT DeleteKey([in] const BSTR name);

    [id(DISPID_SDKDeleteValue)]
    HRESULT DeleteValue([in] const BSTR name);

    [id(DISPID_SDKEnumKeys)]
    HRESULT EnumKeys([in] long index, [out,retval] BSTR *name);

    [id(DISPID_SDKEnumValues)]
    HRESULT EnumValues([in] long Index, [out,retval] BSTR *value);
}

typedef enum SpeechDataKeyLocation
{
    SDKLDefaultLocation = 0,
    SDKLCurrentUser     = 1,
    SDKLLocalMachine    = 2,
    SDKLCurrentConfig   = 5
} SpeechDataKeyLocation;

typedef enum SpeechBookmarkOptions
{
    SBONone  = SPBO_NONE,
    SBOPause = SPBO_PAUSE
} SpeechBookmarkOptions;

#define CLSCTXALL (CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER)

typedef enum SpeechTokenContext
{
    STCInprocServer     = CLSCTX_INPROC_SERVER,
    STCInprocHandler    = CLSCTX_INPROC_HANDLER,
    STCLocalServer      = CLSCTX_LOCAL_SERVER,
    STCRemoteServer     = CLSCTX_REMOTE_SERVER,
    STCAll              = CLSCTXALL
} SpeechTokenContext;

typedef [hidden] enum DISPID_SpeechObjectTokenCategory
{
    DISPID_SOTCId = 1,
    DISPID_SOTCDefault,
    DISPID_SOTCSetId,
    DISPID_SOTCGetDataKey,
    DISPID_SOTCEnumerateTokens,
} DISPID_SpeechObjectTokenCategory;

[
    object,
    uuid(ca7eac50-2d01-4145-86d4-5ae7d70f4469),
    dual,
    pointer_default(unique)
]
interface ISpeechObjectTokenCategory : IDispatch
{
    [propget, id(DISPID_SOTCId)]
    HRESULT Id([out, retval] BSTR *id);

    [propput, id(DISPID_SOTCDefault)]
    HRESULT Default([in] const BSTR token);
    [propget, id(DISPID_SOTCDefault)]
    HRESULT Default([out, retval] BSTR *token);

    [id(DISPID_SOTCSetId)]
    HRESULT SetId([in] const BSTR id, [in, defaultvalue(0)] VARIANT_BOOL created);

    [hidden, id(DISPID_SOTCGetDataKey)]
    HRESULT GetDataKey([in, defaultvalue(SDKLDefaultLocation)] SpeechDataKeyLocation location,
                       [out, retval] ISpeechDataKey **key);

    [id(DISPID_SOTCEnumerateTokens)]
    HRESULT EnumerateTokens([in, defaultvalue("")] BSTR required,
                             [in, defaultvalue("")] BSTR optional,
                             [out, retval] ISpeechObjectTokens **tokens);
}

typedef [hidden] enum DISPID_SpeechObjectToken
{
    DISPID_SOTId                        = 1,
    DISPID_SOTDataKey,
    DISPID_SOTCategory,
    DISPID_SOTGetDescription,
    DISPID_SOTSetId,
    DISPID_SOTGetAttribute,
    DISPID_SOTCreateInstance,
    DISPID_SOTRemove,
    DISPID_SOTGetStorageFileName,
    DISPID_SOTRemoveStorageFileName,
    DISPID_SOTIsUISupported,
    DISPID_SOTDisplayUI,
    DISPID_SOTMatchesAttributes
} DISPID_SpeechObjectToken;

[
    object,
    uuid(c74a3adc-b727-4500-a84a-b526721c8b8c),
    dual,
    pointer_default(unique)
]
interface ISpeechObjectToken : IDispatch
{
    [propget, id(DISPID_SOTId)]
    HRESULT Id([out,retval] BSTR *object);

    [propget, id(DISPID_SOTDataKey), hidden]
    HRESULT DataKey([out,retval] ISpeechDataKey **key);

    [propget, id(DISPID_SOTCategory)]
    HRESULT Category([out,retval] ISpeechObjectTokenCategory **category);

    [id(DISPID_SOTGetDescription)]
    HRESULT GetDescription( [in,defaultvalue(0)] long locale,  [out,retval]BSTR *description);

    [hidden, id(DISPID_SOTSetId)]
    HRESULT SetId([in] BSTR id, [in, defaultvalue("")] BSTR category, [in, defaultvalue(0)] VARIANT_BOOL create);

    [id(DISPID_SOTGetAttribute)]
    HRESULT GetAttribute([in] BSTR name, [out, retval] BSTR* value);

    [id(DISPID_SOTCreateInstance)]
    HRESULT CreateInstance([in, defaultvalue(NULL)] IUnknown *outer,  [in, defaultvalue(STCAll)] SpeechTokenContext spcontext,
                                [out, retval] IUnknown **object);

    [hidden, id(DISPID_SOTRemove)]
    HRESULT Remove([in] BSTR clsid);

    [hidden, id(DISPID_SOTGetStorageFileName)]
    HRESULT GetStorageFileName([in] BSTR clsid, [in] BSTR key, [in] BSTR name, [in] SpeechTokenShellFolder folder,
                                [out,retval] BSTR* path);

    [hidden, id(DISPID_SOTRemoveStorageFileName)]
    HRESULT RemoveStorageFileName([in] BSTR clsid, [in]BSTR key, [in] VARIANT_BOOL delete);

    [hidden, id(DISPID_SOTIsUISupported)]
    HRESULT IsUISupported( [in]const BSTR type, [in, defaultvalue(NULL)] const VARIANT *data,
                               [in, defaultvalue(NULL)] IUnknown *object,
                               [out,retval] VARIANT_BOOL *supported);

    [hidden, id(DISPID_SOTDisplayUI)]
    HRESULT DisplayUI([in] long hwnd, [in] BSTR title, [in]const BSTR type,
                           [in, defaultvalue(NULL)] const VARIANT *data,
                           [in, defaultvalue(NULL)] IUnknown *object);

    [id(DISPID_SOTMatchesAttributes)]
    HRESULT MatchesAttributes([in] BSTR attributes, [out,retval] VARIANT_BOOL *matches);
}

typedef [hidden] enum DISPID_SpeechObjectTokens
{
    DISPID_SOTsCount    = 1,
    DISPID_SOTsItem     = DISPID_VALUE,
    DISPID_SOTs_NewEnum = DISPID_NEWENUM
} DISPID_SpeechObjectTokens;

[
    object,
    uuid(9285b776-2e7b-4bc0-b53e-580eb6fa967f),
    dual,
    pointer_default(unique)
]
interface ISpeechObjectTokens : IDispatch
{
    [propget, id(DISPID_SOTsCount)]
    HRESULT Count([out, retval] long* count);

    [id(DISPID_VALUE)]
    HRESULT Item([in] long index, [out, retval] ISpeechObjectToken **token);

    [propget, restricted, id(DISPID_NEWENUM)]
    HRESULT _NewEnum([out, retval] IUnknown **ppenum);
}

typedef [hidden] enum DISPID_SpeechWaveFormatEx
{
    DISPID_SWFEFormatTag = 1,
    DISPID_SWFEChannels,
    DISPID_SWFESamplesPerSec,
    DISPID_SWFEAvgBytesPerSec,
    DISPID_SWFEBlockAlign,
    DISPID_SWFEBitsPerSample,
    DISPID_SWFEExtraData
} DISPID_SpeechWaveFormatEx;

[
    object,
    uuid(7a1ef0d5-1581-4741-88e4-209a49f11a10),
    dual,
    pointer_default(unique)
]
interface ISpeechWaveFormatEx : IDispatch
{
    [propget, id(DISPID_SWFEFormatTag)]
    HRESULT FormatTag([out,retval] short *tag);
    [propput, id(DISPID_SWFEFormatTag)]
    HRESULT FormatTag([in] short tag);

    [propget, id(DISPID_SWFEChannels)]
    HRESULT Channels([out,retval] short *channels);
    [propput, id(DISPID_SWFEChannels)]
    HRESULT Channels([in] short channels);

    [propget, id(DISPID_SWFESamplesPerSec)]
    HRESULT SamplesPerSec([out,retval] long * samples);
    [propput, id(DISPID_SWFESamplesPerSec)]
    HRESULT SamplesPerSec([in] long samples);

    [propget, id(DISPID_SWFEAvgBytesPerSec)]
    HRESULT AvgBytesPerSec([out,retval] long *average);
    [propput, id(DISPID_SWFEAvgBytesPerSec)]
    HRESULT AvgBytesPerSec([in] long average);

    [propget, id(DISPID_SWFEBlockAlign)]
    HRESULT BlockAlign([out,retval] short *alignment);
    [propput, id(DISPID_SWFEBlockAlign)]
    HRESULT BlockAlign([in] short alignment);

    [propget, id(DISPID_SWFEBitsPerSample)]
    HRESULT BitsPerSample([out,retval] short *bits);
    [propput, id(DISPID_SWFEBitsPerSample)]
    HRESULT BitsPerSample([in] short bits);

    [propget, id(DISPID_SWFEExtraData)]
    HRESULT ExtraData([out,retval] VARIANT *data);
    [propput, id(DISPID_SWFEExtraData)]
    HRESULT ExtraData([in] VARIANT data);
}

typedef enum SpeechAudioFormatType
{
    SAFTDefault = -1,
    SAFTNoAssignedFormat = 0,
    SAFTText,
    SAFTNonStandardFormat,
    SAFTExtendedAudioFormat,
    SAFT8kHz8BitMono,
    SAFT8kHz8BitStereo,
    SAFT8kHz16BitMono,
    SAFT8kHz16BitStereo,
    SAFT11kHz8BitMono,
    SAFT11kHz8BitStereo,
    SAFT11kHz16BitMono,
    SAFT11kHz16BitStereo,
    SAFT12kHz8BitMono,
    SAFT12kHz8BitStereo,
    SAFT12kHz16BitMono,
    SAFT12kHz16BitStereo,
    SAFT16kHz8BitMono,
    SAFT16kHz8BitStereo,
    SAFT16kHz16BitMono,
    SAFT16kHz16BitStereo,
    SAFT22kHz8BitMono,
    SAFT22kHz8BitStereo,
    SAFT22kHz16BitMono,
    SAFT22kHz16BitStereo,
    SAFT24kHz8BitMono,
    SAFT24kHz8BitStereo,
    SAFT24kHz16BitMono,
    SAFT24kHz16BitStereo,
    SAFT32kHz8BitMono,
    SAFT32kHz8BitStereo,
    SAFT32kHz16BitMono,
    SAFT32kHz16BitStereo,
    SAFT44kHz8BitMono,
    SAFT44kHz8BitStereo,
    SAFT44kHz16BitMono,
    SAFT44kHz16BitStereo,
    SAFT48kHz8BitMono,
    SAFT48kHz8BitStereo,
    SAFT48kHz16BitMono,
    SAFT48kHz16BitStereo,
    SAFTTrueSpeech_8kHz1BitMono,
    SAFTCCITT_ALaw_8kHzMono,
    SAFTCCITT_ALaw_8kHzStereo,
    SAFTCCITT_ALaw_11kHzMono,
    SAFTCCITT_ALaw_11kHzStereo,
    SAFTCCITT_ALaw_22kHzMono,
    SAFTCCITT_ALaw_22kHzStereo,
    SAFTCCITT_ALaw_44kHzMono,
    SAFTCCITT_ALaw_44kHzStereo,
    SAFTCCITT_uLaw_8kHzMono,
    SAFTCCITT_uLaw_8kHzStereo,
    SAFTCCITT_uLaw_11kHzMono,
    SAFTCCITT_uLaw_11kHzStereo,
    SAFTCCITT_uLaw_22kHzMono,
    SAFTCCITT_uLaw_22kHzStereo,
    SAFTCCITT_uLaw_44kHzMono,
    SAFTCCITT_uLaw_44kHzStereo,
    SAFTADPCM_8kHzMono,
    SAFTADPCM_8kHzStereo,
    SAFTADPCM_11kHzMono,
    SAFTADPCM_11kHzStereo,
    SAFTADPCM_22kHzMono,
    SAFTADPCM_22kHzStereo,
    SAFTADPCM_44kHzMono,
    SAFTADPCM_44kHzStereo,
    SAFTGSM610_8kHzMono,
    SAFTGSM610_11kHzMono,
    SAFTGSM610_22kHzMono,
    SAFTGSM610_44kHzMono,
} SpeechAudioFormatType;

typedef [hidden] enum DISPID_SpeechAudioFormat
{
    DISPID_SAFType = 1,
    DISPID_SAFGuid,
    DISPID_SAFGetWaveFormatEx,
    DISPID_SAFSetWaveFormatEx
} DISPID_SpeechAudioFormat;

[
    object,
    uuid(e6e9c590-3e18-40e3-8299-061f98bde7c7),
    dual,
    pointer_default(unique)
]
interface ISpeechAudioFormat : IDispatch
{
    [propget, id(DISPID_SAFType)]
    HRESULT Type([out,retval] SpeechAudioFormatType *format);
    [propput, id(DISPID_SAFType)]
    HRESULT Type([in] SpeechAudioFormatType format);

    [propget, hidden, id(DISPID_SAFGuid)]
    HRESULT Guid([out,retval] BSTR *guid);
    [propput, hidden, id(DISPID_SAFGuid)]
    HRESULT Guid([in] BSTR guid);

    [hidden, id(DISPID_SAFGetWaveFormatEx)]
    HRESULT GetWaveFormatEx([out,retval] ISpeechWaveFormatEx **speechwave);

    [hidden, id(DISPID_SAFSetWaveFormatEx)]
    HRESULT SetWaveFormatEx([in] ISpeechWaveFormatEx *speechwave);
}

typedef enum SpeechStreamSeekPositionType
{
    SSSPTRelativeToStart           = STREAM_SEEK_SET,
    SSSPTRelativeToCurrentPosition = STREAM_SEEK_CUR,
    SSSPTRelativeToEnd             = STREAM_SEEK_END
} SpeechStreamSeekPositionType;

typedef [hidden] enum DISPID_SpeechBaseStream
{
    DISPID_SBSFormat = 1,
    DISPID_SBSRead,
    DISPID_SBSWrite,
    DISPID_SBSSeek
} DISPID_SpeechBaseStream;

[
    object,
    uuid(6450336f-7d49-4ced-8097-49d6dee37294),
    dual,
    pointer_default(unique)
]
interface ISpeechBaseStream : IDispatch
{
    [propget, id(DISPID_SBSFormat)]
    HRESULT Format([out,retval] ISpeechAudioFormat **format);
    [propputref, id(DISPID_SBSFormat)]
    HRESULT Format([in] ISpeechAudioFormat *format);

    [id(DISPID_SBSRead)]
    HRESULT Read([out] VARIANT *buffer, [in] long written, [out,retval] long *read);

    [id(DISPID_SBSWrite)]
    HRESULT Write([in] VARIANT buffer, [out,retval] long *written);

    [id(DISPID_SBSSeek)]
    HRESULT Seek([in] VARIANT position, [in, defaultvalue(SSSPTRelativeToStart)] SpeechStreamSeekPositionType origin,
                    [out,retval] VARIANT *pos);
}

typedef [hidden] enum DISPID_SpeechAudioStatus
{
    DISPID_SASFreeBufferSpace = 1,
    DISPID_SASNonBlockingIO,
    DISPID_SASState,
    DISPID_SASCurrentSeekPosition,
    DISPID_SASCurrentDevicePosition
} DISPID_SpeechAudioStatus;

[
    object,
    uuid(c62d9c91-7458-47f6-862d-1ef86fb0b278),
    dual,
    pointer_default(unique)
]
interface ISpeechAudioStatus : IDispatch
{
    [propget, id(DISPID_SASFreeBufferSpace)]
    HRESULT FreeBufferSpace([out,retval] long *space);

    [propget, id(DISPID_SASNonBlockingIO)]
    HRESULT NonBlockingIO([out,retval] long *nonblocking);

    [propget, id(DISPID_SASState)]
    HRESULT State([out, retval] SpeechAudioState *state);

    [propget, id(DISPID_SASCurrentSeekPosition)]
    HRESULT CurrentSeekPosition([out,retval] VARIANT *position);

    [propget, id(DISPID_SASCurrentDevicePosition)]
    HRESULT CurrentDevicePosition([out,retval] VARIANT *position);
}

typedef [hidden] enum DISPID_SpeechRecognizerStatus
{
    DISPID_SRSAudioStatus = 1,
    DISPID_SRSCurrentStreamPosition,
    DISPID_SRSCurrentStreamNumber,
    DISPID_SRSNumberOfActiveRules,
    DISPID_SRSClsidEngine,
    DISPID_SRSSupportedLanguages
} DISPID_SpeechRecognizerStatus;

[
    object,
    uuid(bff9e781-53ec-484e-bb8a-0e1b5551e35c),
    dual,
    pointer_default(unique)
]
interface ISpeechRecognizerStatus : IDispatch
{
    [propget, id(DISPID_SRSAudioStatus)]
    HRESULT AudioStatus([out,retval] ISpeechAudioStatus **audio);

    [propget, id(DISPID_SRSCurrentStreamPosition)]
    HRESULT CurrentStreamPosition([out,retval] VARIANT *pos);

    [propget, id(DISPID_SRSCurrentStreamNumber)]
    HRESULT CurrentStreamNumber([out,retval] long *number);

    [propget, id(DISPID_SRSNumberOfActiveRules)]
    HRESULT NumberOfActiveRules([out,retval] long *rules);

    [propget, id(DISPID_SRSClsidEngine)]
    HRESULT ClsidEngine([out,retval] BSTR *clsid);

    [propget, id(DISPID_SRSSupportedLanguages)]
    HRESULT SupportedLanguages([out,retval] VARIANT *languages);
}

typedef [hidden] enum DISPID_SpeechVoiceStatus
{
    DISPID_SVSCurrentStreamNumber = 1,
    DISPID_SVSLastStreamNumberQueued,
    DISPID_SVSLastResult,
    DISPID_SVSRunningState,
    DISPID_SVSInputWordPosition,
    DISPID_SVSInputWordLength,
    DISPID_SVSInputSentencePosition,
    DISPID_SVSInputSentenceLength,
    DISPID_SVSLastBookmark,
    DISPID_SVSLastBookmarkId,
    DISPID_SVSPhonemeId,
    DISPID_SVSVisemeId
} DISPID_SpeechVoiceStatus;

[
    object,
    uuid(8be47b07-57f6-11d2-9eee-00c04f797396),
    dual,
    pointer_default(unique)
]
interface ISpeechVoiceStatus : IDispatch
{
    [propget, id(DISPID_SVSCurrentStreamNumber)]
    HRESULT CurrentStreamNumber([out, retval] long *number);

    [propget, id(DISPID_SVSLastStreamNumberQueued)]
    HRESULT LastStreamNumberQueued([out, retval] long *number);

    [propget, id(DISPID_SVSLastResult)]
    HRESULT LastHResult([out, retval]long *result);

    [propget, id(DISPID_SVSRunningState)]
    HRESULT RunningState([out, retval] SpeechRunState *state);

    [propget, id(DISPID_SVSInputWordPosition)]
    HRESULT InputWordPosition([out, retval] long *position);

    [propget, id(DISPID_SVSInputWordLength)]
    HRESULT InputWordLength([out, retval] long *length);

    [propget, id(DISPID_SVSInputSentencePosition)]
    HRESULT InputSentencePosition([out, retval] long *position);

    [propget, id(DISPID_SVSInputSentenceLength)]
    HRESULT InputSentenceLength([out, retval] long *length);

    [propget, id(DISPID_SVSLastBookmark)]
    HRESULT LastBookmark([out, retval] BSTR *bookmark);

    [propget, id(DISPID_SVSLastBookmarkId), hidden]
    HRESULT LastBookmarkId([out, retval] long *bookmark);

    [propget, id(DISPID_SVSPhonemeId)]
    HRESULT PhonemeId([out, retval] short *phone);

    [propget, id(DISPID_SVSVisemeId)]
    HRESULT VisemeId([out, retval] short *id);
}

typedef [hidden] enum DISPID_SpeechVoice
{
    DISPID_SVStatus = 1,
    DISPID_SVVoice,
    DISPID_SVAudioOutput,
    DISPID_SVAudioOutputStream,
    DISPID_SVRate,
    DISPID_SVVolume,
    DISPID_SVAllowAudioOuputFormatChangesOnNextSet,
    DISPID_SVEventInterests,
    DISPID_SVPriority,
    DISPID_SVAlertBoundary,
    DISPID_SVSyncronousSpeakTimeout,
    DISPID_SVSpeak,
    DISPID_SVSpeakStream,
    DISPID_SVPause,
    DISPID_SVResume,
    DISPID_SVSkip,
    DISPID_SVGetVoices,
    DISPID_SVGetAudioOutputs,
    DISPID_SVWaitUntilDone,
    DISPID_SVSpeakCompleteEvent,
    DISPID_SVIsUISupported,
    DISPID_SVDisplayUI
} DISPID_SpeechVoice;

[
    object,
    uuid(269316d8-57bd-11d2-9eee-00c04f797396),
    dual,
    pointer_default(unique)
]
interface ISpeechVoice : IDispatch
{
    [propget, id(DISPID_SVStatus)]
    HRESULT Status([out, retval] ISpeechVoiceStatus **Status);

    [propget, id(DISPID_SVVoice)]
    HRESULT Voice([out, retval] ISpeechObjectToken **voice);

    [propputref, id(DISPID_SVVoice)]
    HRESULT Voice([in] ISpeechObjectToken *voice);

    [propget, id(DISPID_SVAudioOutput)]
    HRESULT AudioOutput([out, retval] ISpeechObjectToken **output);

    [propputref, id(DISPID_SVAudioOutput)]
    HRESULT AudioOutput([in] ISpeechObjectToken *output);

    [propget, id(DISPID_SVAudioOutputStream)]
    HRESULT AudioOutputStream([out, retval] ISpeechBaseStream **output);

    [propputref, id(DISPID_SVAudioOutputStream)]
    HRESULT AudioOutputStream([in] ISpeechBaseStream *output);

    [propget, id(DISPID_SVRate)]
    HRESULT Rate([out, retval] long *rate);

    [propput, id(DISPID_SVRate)]
    HRESULT Rate([in] long rate);

    [propget, id(DISPID_SVVolume)]
    HRESULT Volume([out, retval] long *volume);

    [propput, id(DISPID_SVVolume)]
    HRESULT Volume([in] long volume);

    [propput, hidden, id(DISPID_SVAllowAudioOuputFormatChangesOnNextSet)]
    HRESULT AllowAudioOutputFormatChangesOnNextSet([in] VARIANT_BOOL allow);

    [propget, hidden, id(DISPID_SVAllowAudioOuputFormatChangesOnNextSet)]
    HRESULT AllowAudioOutputFormatChangesOnNextSet([out,retval] VARIANT_BOOL *allow);

    [propget, id(DISPID_SVEventInterests)]
    HRESULT EventInterests([out,retval] SpeechVoiceEvents *flags);

    [propput, id(DISPID_SVEventInterests)]
    HRESULT EventInterests([in] SpeechVoiceEvents flags);

    [propput, id(DISPID_SVPriority)]
    HRESULT Priority([in] SpeechVoicePriority vpriority);

    [propget, id(DISPID_SVPriority)]
    HRESULT Priority([out,retval] SpeechVoicePriority *vpriority);

    [propput, id(DISPID_SVAlertBoundary)]
    HRESULT AlertBoundary([in] SpeechVoiceEvents boundary);

    [propget, id(DISPID_SVAlertBoundary)]
    HRESULT AlertBoundary([out,retval] SpeechVoiceEvents *boundary);

    [propput, id(DISPID_SVSyncronousSpeakTimeout)]
    HRESULT SynchronousSpeakTimeout([in] long timeout);

    [propget, id(DISPID_SVSyncronousSpeakTimeout)]
    HRESULT SynchronousSpeakTimeout([out,retval] long *timeout);

    [id(DISPID_SVSpeak)]
    HRESULT Speak([in] BSTR text, [in, defaultvalue(SPF_DEFAULT)] SpeechVoiceSpeakFlags flags,
                       [out, retval] long *number);

    [id(DISPID_SVSpeakStream)]
    HRESULT SpeakStream([in] ISpeechBaseStream *stream, [in, defaultvalue(SPF_DEFAULT)] SpeechVoiceSpeakFlags flags,
                             [out, retval] long *number);

    [id(DISPID_SVPause)]
    HRESULT Pause(void);

    [id(DISPID_SVResume)]
    HRESULT Resume(void);

    [id(DISPID_SVSkip)]
    HRESULT Skip([in] const BSTR type, [in] long items, [out,retval ]long *skipped);

    [id(DISPID_SVGetVoices)]
    HRESULT GetVoices([in, defaultvalue("")] BSTR required, [in, defaultvalue("")] BSTR optional,
                          [out,retval] ISpeechObjectTokens **tokens);

    [id(DISPID_SVGetAudioOutputs)]
    HRESULT GetAudioOutputs([in, defaultvalue("")] BSTR required, [in, defaultvalue("")] BSTR optional,
                                [out,retval] ISpeechObjectTokens **tokens);

    [id(DISPID_SVWaitUntilDone)]
    HRESULT WaitUntilDone([in] long msTimeout, [out,retval] VARIANT_BOOL *done);

    [hidden, id(DISPID_SVSpeakCompleteEvent)]
    HRESULT SpeakCompleteEvent([out,retval] long *handle);

    [id(DISPID_SVIsUISupported)]
        HRESULT IsUISupported( [in] const BSTR typeui, [in, defaultvalue(NULL)] const VARIANT *data,
                               [out,retval] VARIANT_BOOL *supported);

    [id(DISPID_SVDisplayUI)]
    HRESULT DisplayUI([in] long hwnd, [in] BSTR title, [in] const BSTR typeui, [in, defaultvalue(NULL)] const VARIANT *data);
}

typedef [hidden] enum DISPID_SpeechRecoResultTimes
{
    DISPID_SRRTStreamTime = 1,
    DISPID_SRRTLength,
    DISPID_SRRTTickCount,
    DISPID_SRRTOffsetFromStart
} DISPID_SpeechRecoResultTimes;

[
    object,
    uuid(62b3b8fb-f6e7-41be-bdcb-056b1c29efc0),
    dual,
    pointer_default(unique)
]
interface ISpeechRecoResultTimes : IDispatch
{
    [propget, id(DISPID_SRRTStreamTime)]
    HRESULT StreamTime([out,retval] VARIANT *streamtime);

    [propget, id(DISPID_SRRTLength)]
    HRESULT Length([out,retval] VARIANT *length);

    [propget, id(DISPID_SRRTTickCount)]
    HRESULT TickCount([out,retval] long *count);

    [propget, id(DISPID_SRRTOffsetFromStart)]
    HRESULT OffsetFromStart([out,retval] VARIANT *offset);
}

typedef [hidden] enum DISPID_SpeechPhraseRules
{
    DISPID_SPRulesCount    = 1,
    DISPID_SPRulesItem     = DISPID_VALUE,
    DISPID_SPRules_NewEnum = DISPID_NEWENUM
} DISPID_SpeechPhraseRules;

[
    object,
    uuid(9047d593-01dd-4b72-81a3-e4a0ca69f407),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseRules : IDispatch
{
    [propget, id(DISPID_SPRulesCount)]
    HRESULT Count([out, retval] long *count);

    [id(DISPID_SPRulesItem)]
    HRESULT Item([in] long index, [out, retval] ISpeechPhraseRule **rule);

    [propget, restricted, id(DISPID_SPRules_NewEnum)]
    HRESULT _NewEnum([out, retval] IUnknown **obj);
}

typedef [hidden] enum DISPID_SpeechPhraseRule
{
    DISPID_SPRuleName = 1,
    DISPID_SPRuleId,
    DISPID_SPRuleFirstElement,
    DISPID_SPRuleNumberOfElements,
    DISPID_SPRuleParent,
    DISPID_SPRuleChildren,
    DISPID_SPRuleConfidence,
    DISPID_SPRuleEngineConfidence
} DISPID_SpeechPhraseRule;

[
    object,
    uuid(a7bfe112-a4a0-48d9-b602-c313843f6964),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseRule : IDispatch
{
    [propget, id(DISPID_SPRuleName)]
    HRESULT Name([out, retval]BSTR *name);

    [propget, id(DISPID_SPRuleId)]
    HRESULT Id( [out, retval] long *id);

    [propget, id(DISPID_SPRuleFirstElement)]
    HRESULT FirstElement([out, retval] long *element);

    [propget, id(DISPID_SPRuleNumberOfElements)]
    HRESULT NumberOfElements([out, retval] long *count);

    [propget, id(DISPID_SPRuleParent)]
    HRESULT Parent([out, retval] ISpeechPhraseRule **parent);

    [propget, id(DISPID_SPRuleChildren)]
    HRESULT Children([out, retval] ISpeechPhraseRules **children);

    [propget, id(DISPID_SPRuleConfidence)]
    HRESULT Confidence([out, retval] SpeechEngineConfidence *confidence);

    [propget, id(DISPID_SPRuleEngineConfidence)]
    HRESULT EngineConfidence([out, retval] float *confidence);
}

typedef [hidden] enum DISPID_SpeechPhraseProperty
{
    DISPID_SPPName = 1,
    DISPID_SPPId,
    DISPID_SPPValue,
    DISPID_SPPFirstElement,
    DISPID_SPPNumberOfElements,
    DISPID_SPPEngineConfidence,
    DISPID_SPPConfidence,
    DISPID_SPPParent,
    DISPID_SPPChildren
} DISPID_SpeechPhraseProperty;

[
    object,
    uuid(CE563D48-961E-4732-A2E1-378A42B430BE),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseProperty : IDispatch
{
    [propget, id(DISPID_SPPName)]
    HRESULT Name([out, retval] BSTR *name);

    [propget, id(DISPID_SPPId)]
    HRESULT Id([out, retval] long *id);

    [propget, id(DISPID_SPPValue)]
    HRESULT Value([out, retval] VARIANT *value);

    [propget, id(DISPID_SPPFirstElement)]
    HRESULT FirstElement( [out, retval] long *element);

    [propget, id(DISPID_SPPNumberOfElements)]
    HRESULT NumberOfElements([out, retval] long *elements);

    [propget, id(DISPID_SPPEngineConfidence)]
    HRESULT EngineConfidence([out, retval] float *confidence);

    [propget, id(DISPID_SPPConfidence)]
    HRESULT Confidence([out, retval] SpeechEngineConfidence *Confidence);

    [propget, id(DISPID_SPPParent)]
    HRESULT Parent([out, retval] ISpeechPhraseProperty **parent);

    [propget, id(DISPID_SPPChildren)]
    HRESULT Children( [out, retval] ISpeechPhraseProperties **children);
}

typedef [hidden] enum DISPID_SpeechPhraseProperties
{
    DISPID_SPPsCount = 1,
    DISPID_SPPsItem = DISPID_VALUE,
    DISPID_SPPs_NewEnum = DISPID_NEWENUM
} DISPID_SpeechPhraseProperties;

[
    object,
    uuid(08166b47-102e-4b23-a599-bdb98dbfd1f4),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseProperties : IDispatch
{
    [propget, id(DISPID_SPPsCount)]
    HRESULT Count([out, retval] long *count);

    [id(DISPID_SPPsItem)]
    HRESULT Item([in] long index, [out, retval] ISpeechPhraseProperty **obj);

    [propget, restricted, id(DISPID_SPPs_NewEnum)]
    HRESULT _NewEnum([out, retval] IUnknown **obj);
}

typedef [hidden] enum DISPID_SpeechPhraseElement
{
    DISPID_SPEAudioTimeOffset = 1,
    DISPID_SPEAudioSizeTime,
    DISPID_SPEAudioStreamOffset,
    DISPID_SPEAudioSizeBytes,
    DISPID_SPERetainedStreamOffset,
    DISPID_SPERetainedSizeBytes,
    DISPID_SPEDisplayText,
    DISPID_SPELexicalForm,
    DISPID_SPEPronunciation,
    DISPID_SPEDisplayAttributes,
    DISPID_SPERequiredConfidence,
    DISPID_SPEActualConfidence,
    DISPID_SPEEngineConfidence
} DISPID_SpeechPhraseElement;

[
    object,
    uuid(e6176f96-e373-4801-b223-3b62c068c0b4),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseElement : IDispatch
{
    [propget, id(DISPID_SPEAudioTimeOffset)]
    HRESULT AudioTimeOffset( [out, retval] long *offset);

    [propget, id(DISPID_SPEAudioSizeTime)]
    HRESULT AudioSizeTime([out, retval] long *audiotime);

    [propget, id(DISPID_SPEAudioStreamOffset)]
    HRESULT AudioStreamOffset([out, retval] long *offset);

    [propget, id(DISPID_SPEAudioSizeBytes)]
    HRESULT AudioSizeBytes([out, retval]long *bytes);

    [propget, id(DISPID_SPERetainedStreamOffset)]
    HRESULT RetainedStreamOffset([out, retval] long *offset);

    [propget, id(DISPID_SPERetainedSizeBytes)]
    HRESULT RetainedSizeBytes([out, retval] long *retained);

    [propget, id(DISPID_SPEDisplayText)]
    HRESULT DisplayText([out, retval] BSTR *display);

    [propget, id(DISPID_SPELexicalForm)]
    HRESULT LexicalForm( [out, retval] BSTR *lexical);

    [propget, id(DISPID_SPEPronunciation)]
    HRESULT Pronunciation([out, retval] VARIANT *pronunciation);

    [propget, id(DISPID_SPEDisplayAttributes)]
    HRESULT DisplayAttributes([out, retval] SpeechDisplayAttributes *attributes);

    [propget, id(DISPID_SPERequiredConfidence)]
    HRESULT RequiredConfidence([out, retval] SpeechEngineConfidence *confidence);

    [propget, id(DISPID_SPEActualConfidence)]
    HRESULT ActualConfidence([out, retval] SpeechEngineConfidence *confidence);

    [propget, id(DISPID_SPEEngineConfidence)]
    HRESULT EngineConfidence([out, retval] float *confidence);
}

typedef [hidden] enum DISPID_SpeechPhraseElements
{
    DISPID_SPEsCount    = 1,
    DISPID_SPEsItem     = DISPID_VALUE,
    DISPID_SPEs_NewEnum = DISPID_NEWENUM
} DISPID_SpeechPhraseElements;

[
    object,
    uuid(0626b328-3478-467d-a0b3-d0853b93dda3),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseElements : IDispatch
{
    [propget, id(DISPID_SPEsCount)]
    HRESULT Count([out, retval] long *count);

    [id(DISPID_SPEsItem)]
    HRESULT Item([in] long Index, [out, retval] ISpeechPhraseElement **element);

    [propget, restricted, id(DISPID_SPEs_NewEnum)]
    HRESULT _NewEnum([out, retval] IUnknown **obj);
}

typedef [hidden] enum DISPID_SpeechPhraseReplacement
{
    DISPID_SPRDisplayAttributes = 1,
    DISPID_SPRText,
    DISPID_SPRFirstElement,
    DISPID_SPRNumberOfElements
} DISPID_SpeechPhraseReplacement;

[
    object,
    uuid(2890a410-53a7-4fb5-94ec-06d4998e3d02),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseReplacement : IDispatch
{
    [propget, id(DISPID_SPRDisplayAttributes)]
    HRESULT DisplayAttributes([out,retval] SpeechDisplayAttributes *attributes);

    [propget, id(DISPID_SPRText)]
    HRESULT Text([out, retval] BSTR *text);

    [propget, id(DISPID_SPRFirstElement)]
    HRESULT FirstElement([out, retval] long *element);

    [propget, id(DISPID_SPRNumberOfElements)]
    HRESULT NumberOfElements([out, retval] long *elements);
}

typedef [hidden] enum DISPID_SpeechPhraseReplacements
{
    DISPID_SPRsCount = 1,
    DISPID_SPRsItem = DISPID_VALUE,
    DISPID_SPRs_NewEnum = DISPID_NEWENUM
} DISPID_SpeechPhraseReplacements;

[
    object,
    uuid(38bc662f-2257-4525-959e-2069d2596c05),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseReplacements : IDispatch
{
    [propget, id(DISPID_SPRsCount)]
    HRESULT Count([out, retval] long *count);

    [id(DISPID_SPRsItem)]
    HRESULT Item([in] long index, [out, retval] ISpeechPhraseReplacement **reps);

    [propget, restricted, id(DISPID_SPRs_NewEnum)]
    HRESULT _NewEnum([out, retval] IUnknown **obj);
}

typedef [hidden] enum DISPID_SpeechPhraseInfo
{
    DISPID_SPILanguageId = 1,
    DISPID_SPIGrammarId,
    DISPID_SPIStartTime,
    DISPID_SPIAudioStreamPosition,
    DISPID_SPIAudioSizeBytes,
    DISPID_SPIRetainedSizeBytes,
    DISPID_SPIAudioSizeTime,
    DISPID_SPIRule,
    DISPID_SPIProperties,
    DISPID_SPIElements,
    DISPID_SPIReplacements,
    DISPID_SPIEngineId,
    DISPID_SPIEnginePrivateData,
    DISPID_SPISaveToMemory,
    DISPID_SPIGetText,
    DISPID_SPIGetDisplayAttributes
} DISPID_SpeechPhraseInfo;

[
    object,
    uuid(961559cf-4e67-4662-8bf0-d93f1fcd61b3),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseInfo : IDispatch
{
    [propget, id(DISPID_SPILanguageId)]
    HRESULT LanguageId( [out, retval] long *language);

    [propget, id(DISPID_SPIGrammarId)]
    HRESULT GrammarId([out, retval] VARIANT *grammar);

    [propget, id(DISPID_SPIStartTime)]
    HRESULT StartTime([out, retval]VARIANT *start);

    [propget, id(DISPID_SPIAudioStreamPosition)]
    HRESULT AudioStreamPosition([out, retval] VARIANT *position);

    [propget, id(DISPID_SPIAudioSizeBytes)]
    HRESULT AudioSizeBytes([out, retval] long *bytes);

    [propget, id(DISPID_SPIRetainedSizeBytes)]
    HRESULT RetainedSizeBytes([out, retval] long *bytes);

    [propget, id(DISPID_SPIAudioSizeTime)]
    HRESULT AudioSizeTime([out, retval] long *audiotime);

    [propget, id(DISPID_SPIRule)]
    HRESULT Rule([out, retval] ISpeechPhraseRule **rule);

    [propget, id(DISPID_SPIProperties)]
    HRESULT Properties([out, retval] ISpeechPhraseProperties **props);

    [propget, id(DISPID_SPIElements)]
    HRESULT Elements([out, retval] ISpeechPhraseElements **elements);

    [propget, id(DISPID_SPIReplacements)]
    HRESULT Replacements([out, retval] ISpeechPhraseReplacements **replacements);

    [propget, id(DISPID_SPIEngineId)]
    HRESULT EngineId([out, retval] BSTR *engine);

    [propget, id(DISPID_SPIEnginePrivateData)]
    HRESULT EnginePrivateData([out, retval] VARIANT *data);

    [id(DISPID_SPISaveToMemory)]
    HRESULT SaveToMemory([out,retval] VARIANT *block);

    [id(DISPID_SPIGetText)]
    HRESULT GetText([in, defaultvalue(0)] long start,
                [in, defaultvalue(SPPR_ALL_ELEMENTS)] long elements,
                [in, defaultvalue(-1)] VARIANT_BOOL replacements, [out,retval] BSTR *text);

    [id(DISPID_SPIGetDisplayAttributes)]
    HRESULT GetDisplayAttributes([in, defaultvalue(0)] long start,
                [in, defaultvalue(SPPR_ALL_ELEMENTS)] long elements,
                [in, defaultvalue(-1)] VARIANT_BOOL replacements,
                [out,retval] SpeechDisplayAttributes *attributes);
}

typedef [hidden] enum DISPID_SpeechPhraseAlternate
{
    DISPID_SPARecoResult = 1,
    DISPID_SPAStartElementInResult,
    DISPID_SPANumberOfElementsInResult,
    DISPID_SPAPhraseInfo,
    DISPID_SPACommit
} DISPID_SpeechPhraseAlternate;

[
    object,
    uuid(27864a2a-2b9f-4cb8-92d3-0d2722fd1e73),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseAlternate : IDispatch
{
    [propget, id(DISPID_SPARecoResult)]
    HRESULT RecoResult( [out,retval] ISpeechRecoResult **result);

    [propget, id(DISPID_SPAStartElementInResult)]
    HRESULT StartElementInResult([out,retval] long *element);

    [propget, id(DISPID_SPANumberOfElementsInResult)]
    HRESULT NumberOfElementsInResult([out,retval] long *elements);

    [propget, id(DISPID_SPAPhraseInfo)]
    HRESULT PhraseInfo( [out,retval] ISpeechPhraseInfo **PhraseInfo);

    [id(DISPID_SPACommit)]
    HRESULT Commit(void);
}

typedef [hidden] enum DISPID_SpeechPhraseAlternates
{
    DISPID_SPAsCount = 1,
    DISPID_SPAsItem = DISPID_VALUE,
    DISPID_SPAs_NewEnum = DISPID_NEWENUM
} DISPID_SpeechPhraseAlternates;

[
    object,
    uuid(b238b6d5-f276-4c3d-a6c1-2974801c3cc2),
    dual,
    pointer_default(unique)
]
interface ISpeechPhraseAlternates : IDispatch
{
    [propget, id(DISPID_SPAsCount)]
    HRESULT Count([out, retval] long *count);

    [id(DISPID_SPAsItem)]
    HRESULT Item([in] long index, [out, retval] ISpeechPhraseAlternate **alternate);

    [propget, restricted, id(DISPID_SPAs_NewEnum)]
    HRESULT _NewEnum([out, retval] IUnknown **obj);
}

typedef [hidden] enum DISPID_SpeechMemoryStream
{
    DISPID_SMSSetData = 100,
    DISPID_SMSGetData
} DISPID_SpeechMemoryStream;

[
    object,
    uuid(eeb14b68-808b-4abe-a5ea-b51da7588008),
    dual,
    pointer_default(unique)
]
interface ISpeechMemoryStream : ISpeechBaseStream
{
    [id(DISPID_SMSSetData)]
    HRESULT SetData([in] VARIANT data);

    [id(DISPID_SMSGetData)]
    HRESULT GetData([out, retval] VARIANT *data);
}

typedef [hidden] enum DISPID_SpeechRecoResult
{
    DISPID_SRRRecoContext = 1,
    DISPID_SRRTimes,
    DISPID_SRRAudioFormat,
    DISPID_SRRPhraseInfo,
    DISPID_SRRAlternates,
    DISPID_SRRAudio,
    DISPID_SRRSpeakAudio,
    DISPID_SRRSaveToMemory,
    DISPID_SRRDiscardResultInfo
} DISPID_SpeechRecoResult;

[
    object,
    uuid(ed2879cf-ced9-4ee6-a534-de0191d5468d),
    dual,
    pointer_default(unique)
]
interface ISpeechRecoResult : IDispatch
{
    [propget, id(DISPID_SRRRecoContext)]
    HRESULT RecoContext( [out,retval] ISpeechRecoContext** RecoContext );

    [propget, id(DISPID_SRRTimes)]
    HRESULT Times([out,retval] ISpeechRecoResultTimes **times);

    [propputref, id(DISPID_SRRAudioFormat)]
    HRESULT AudioFormat([in]ISpeechAudioFormat *format);
    [propget, id(DISPID_SRRAudioFormat)]
    HRESULT AudioFormat([out,retval] ISpeechAudioFormat **format);

    [propget, id(DISPID_SRRPhraseInfo)]
    HRESULT PhraseInfo([out,retval] ISpeechPhraseInfo **phrase);

    [id(DISPID_SRRAlternates)]
    HRESULT Alternates( [in] long count, [in, defaultvalue(0)] long start,
                [in, defaultvalue(SPPR_ALL_ELEMENTS)] long elements,
                [out,retval] ISpeechPhraseAlternates **alternates);

    [id(DISPID_SRRAudio)]
    HRESULT Audio([in, defaultvalue(0)] long start,
                [in, defaultvalue(SPPR_ALL_ELEMENTS)] long elements,
                [out,retval] ISpeechMemoryStream **stream);

    [id(DISPID_SRRSpeakAudio)]
    HRESULT SpeakAudio([in, defaultvalue(0)] long start,
                [in, defaultvalue(SPPR_ALL_ELEMENTS)] long elements,
                [in, defaultvalue(SPF_DEFAULT)] SpeechVoiceSpeakFlags flags,
                [out,retval] long *stream);

    [id(DISPID_SRRSaveToMemory)]
    HRESULT SaveToMemory([out,retval] VARIANT *block);

    [id(DISPID_SRRDiscardResultInfo)]
    HRESULT DiscardResultInfo([in] SpeechDiscardType types);
}

typedef [hidden] enum DISPID_SpeechGrammarRule
{
    DISPID_SGRAttributes = 1,
    DISPID_SGRInitialState,
    DISPID_SGRName,
    DISPID_SGRId,
    DISPID_SGRClear,
    DISPID_SGRAddResource,
    DISPID_SGRAddState
} DISPID_SpeechGrammarRule;

typedef [hidden] enum DISPID_SpeechGrammarRuleStateTransitions
{
    DISPID_SGRSTsCount = 1,
    DISPID_SGRSTsItem = DISPID_VALUE,
    DISPID_SGRSTs_NewEnum = DISPID_NEWENUM
} DISPID_SpeechGrammarRuleStateTransitions;

typedef enum SpeechGrammarRuleStateTransitionType
{
    SGRSTTEpsilon = 0,
    SGRSTTWord,
    SGRSTTRule,
    SGRSTTDictation,
    SGRSTTWildcard,
    SGRSTTTextBuffer
} SpeechGrammarRuleStateTransitionType;

typedef [hidden] enum DISPID_SpeechGrammarRuleStateTransition
{
    DISPID_SGRSTType = 1,
    DISPID_SGRSTText,
    DISPID_SGRSTRule,
    DISPID_SGRSTWeight,
    DISPID_SGRSTPropertyName,
    DISPID_SGRSTPropertyId,
    DISPID_SGRSTPropertyValue,
    DISPID_SGRSTNextState
} DISPID_SpeechGrammarRuleStateTransition;

[
    object,
    uuid(cafd1db1-41d1-4a06-9863-e2e81da17a9a),
    dual,
    pointer_default(unique)
]
interface ISpeechGrammarRuleStateTransition : IDispatch
{
    [propget, id(DISPID_SGRSTType)]
    HRESULT Type([out, retval] SpeechGrammarRuleStateTransitionType *type);

    [propget, id(DISPID_SGRSTText)]
    HRESULT Text([out, retval] BSTR *text);

    [propget, id(DISPID_SGRSTRule)]
    HRESULT Rule([out, retval] ISpeechGrammarRule **rule);

    [propget, id(DISPID_SGRSTWeight)]
    HRESULT Weight([out, retval] VARIANT *weight);

    [propget, id(DISPID_SGRSTPropertyName)]
    HRESULT PropertyName([out, retval] BSTR *name);

    [propget, id(DISPID_SGRSTPropertyId)]
    HRESULT PropertyId([out, retval] long *id);

    [propget, id(DISPID_SGRSTPropertyValue)]
    HRESULT PropertyValue([out, retval] VARIANT *value);

    [propget, id(DISPID_SGRSTNextState)]
    HRESULT NextState([out, retval] ISpeechGrammarRuleState **state);
}

[
    object,
    uuid(EABCE657-75BC-44a2-AA7F-C56476742963),
    dual,
    pointer_default(unique)
]
interface ISpeechGrammarRuleStateTransitions : IDispatch
{
    [propget, id(DISPID_SGRSTsCount)]
    HRESULT Count([out, retval] long *count);

    [id(DISPID_SGRSTsItem)]
    HRESULT Item([in] long index, [out, retval] ISpeechGrammarRuleStateTransition **transition);

    [propget, restricted, id(DISPID_SGRSTs_NewEnum)]
    HRESULT _NewEnum([out, retval] IUnknown **enum_var);
}

typedef [hidden] enum DISPID_SpeechGrammarRuleState
{
    DISPID_SGRSRule = 1,
    DISPID_SGRSTransitions,
    DISPID_SGRSAddWordTransition,
    DISPID_SGRSAddRuleTransition,
    DISPID_SGRSAddSpecialTransition
} DISPID_SpeechGrammarRuleState;

[
    object,
    uuid(d4286f2c-ee67-45ae-b928-28d695362eda),
    dual,
    pointer_default(unique)
]
interface ISpeechGrammarRuleState : IDispatch
{
    [propget, id(DISPID_SGRSRule)]
    HRESULT Rule([out, retval] ISpeechGrammarRule **rule);

    [propget, id(DISPID_SGRSTransitions)]
    HRESULT Transitions([out, retval] ISpeechGrammarRuleStateTransitions **transitions);

    [id(DISPID_SGRSAddWordTransition)]
    HRESULT AddWordTransition([in] ISpeechGrammarRuleState *state, [in] const BSTR Words,
            [in, defaultvalue(" ")] const BSTR separators, [in, defaultvalue(SGLexical)] SpeechGrammarWordType type,
            [in, defaultvalue("")] const BSTR name, [in, defaultvalue(0)] long id,
            [in, defaultvalue(0)] VARIANT *value,  [in, defaultvalue(1)] float weight);

    [id(DISPID_SGRSAddRuleTransition)]
    HRESULT AddRuleTransition([in] ISpeechGrammarRuleState *state, [in] ISpeechGrammarRule *rule,
            [in, defaultvalue("")] const BSTR name, [in, defaultvalue(0)] long id,
            [in, defaultvalue(0)] VARIANT *value, [in, defaultvalue(1)] float weight);

    [id(DISPID_SGRSAddSpecialTransition)]
    HRESULT AddSpecialTransition([in] ISpeechGrammarRuleState *state, [in] SpeechSpecialTransitionType type,
            [in, defaultvalue("")] const BSTR name, [in, defaultvalue(0)] long id,
            [in, defaultvalue(0)] VARIANT* value, [in, defaultvalue(1)] float weight);
}

[
    object,
    uuid(afe719cf-5dd1-44f2-999c-7a399f1cfccc),
    dual,
    pointer_default(unique)
]
interface ISpeechGrammarRule : IDispatch
{
    [propget, id(DISPID_SGRAttributes)]
    HRESULT Attributes([out, retval] SpeechRuleAttributes *attributes);

    [propget, id(DISPID_SGRInitialState)]
    HRESULT InitialState([out, retval] ISpeechGrammarRuleState **state);

    [propget, id(DISPID_SGRName)]
    HRESULT Name([out, retval] BSTR *name);

    [propget, id(DISPID_SGRId)]
    HRESULT Id([out, retval] long *id);

    [id(DISPID_SGRClear)]
    HRESULT Clear();

    [id(DISPID_SGRAddResource)]
    HRESULT AddResource([in] const BSTR name, [in] const BSTR value);

    [id(DISPID_SGRAddState)]
    HRESULT AddState([out, retval] ISpeechGrammarRuleState **state);
}

typedef [hidden] enum DISPIDSPTSI
{
    DISPIDSPTSI_ActiveOffset = 1,
    DISPIDSPTSI_ActiveLength,
    DISPIDSPTSI_SelectionOffset,
    DISPIDSPTSI_SelectionLength
} DISPIDSPTSI;

[
    object,
    uuid(3b9c7e7a-6eee-4ded-9092-11657279adbe),
    dual,
    pointer_default(unique)
]
interface ISpeechTextSelectionInformation : IDispatch
{
    [propput, id(DISPIDSPTSI_ActiveOffset)]
    HRESULT ActiveOffset([in] long offset);
    [propget, id(DISPIDSPTSI_ActiveOffset)]
    HRESULT ActiveOffset([out, retval] long *offset);

    [propput, id(DISPIDSPTSI_ActiveLength)]
    HRESULT ActiveLength([in] long length);
    [propget, id(DISPIDSPTSI_ActiveLength)]
    HRESULT ActiveLength([out, retval] long *length);

    [propput, id(DISPIDSPTSI_SelectionOffset)]
    HRESULT SelectionOffset([in] long offset);
    [propget, id(DISPIDSPTSI_SelectionOffset)]
    HRESULT SelectionOffset([out, retval] long *offset);

    [propput, id(DISPIDSPTSI_SelectionLength)]
    HRESULT SelectionLength([in] long length);
    [propget, id(DISPIDSPTSI_SelectionLength)]
    HRESULT SelectionLength([out, retval] long* length);
}

typedef [hidden] enum DISPID_SpeechGrammarRules
{
    DISPID_SGRsCount = 1,
    DISPID_SGRsDynamic,
    DISPID_SGRsAdd,
    DISPID_SGRsCommit,
    DISPID_SGRsCommitAndSave,
    DISPID_SGRsFindRule,
    DISPID_SGRsItem = DISPID_VALUE,
    DISPID_SGRs_NewEnum = DISPID_NEWENUM
} DISPID_SpeechGrammarRules;

[
    object,
    uuid(6ffa3b44-fc2d-40d1-8afc-32911c7f1ad1),
    dual,
    pointer_default(unique)
]
interface ISpeechGrammarRules : IDispatch
{
    [propget, id(DISPID_SGRsCount)]
    HRESULT Count([out, retval] long *count);

    [id(DISPID_SGRsFindRule)]
    HRESULT FindRule([in] VARIANT id, [out, retval] ISpeechGrammarRule **rule);

    [id(DISPID_SGRsItem)]
    HRESULT Item([in] long index, [out, retval] ISpeechGrammarRule **rule);

    [id(DISPID_SGRs_NewEnum), propget, restricted]
    HRESULT _NewEnum([out, retval] IUnknown **enum_var);

    [propget, id(DISPID_SGRsDynamic)]
    HRESULT Dynamic([out, retval] VARIANT_BOOL *dynamic);

    [id(DISPID_SGRsAdd)]
    HRESULT Add([in] BSTR name, [in] SpeechRuleAttributes attributes,
            [in, defaultvalue(0)] long id, [out, retval] ISpeechGrammarRule **rule);

    [id(DISPID_SGRsCommit)]
    HRESULT Commit(void);

    [id(DISPID_SGRsCommitAndSave)]
    HRESULT CommitAndSave([out] BSTR *text, [out, retval] VARIANT *stream);
}

[
    object,
    uuid(b6d6f79f-2158-4e50-b5bc-9a9ccd852a09),
    dual,
    pointer_default(unique)
]
interface ISpeechRecoGrammar : IDispatch
{
    [propget, id(DISPID_SRGId)]
    HRESULT Id([out, retval] VARIANT *id);

    [propget, id(DISPID_SRGRecoContext)]
    HRESULT RecoContext([out, retval] ISpeechRecoContext **context);

    [propput, id(DISPID_SRGState)]
    HRESULT State([in] SpeechGrammarState state);
    [propget, id(DISPID_SRGState)]
    HRESULT State([out, retval] SpeechGrammarState *state);

    [propget, id(DISPID_SRGRules)]
    HRESULT Rules([out, retval] ISpeechGrammarRules **rules);

    [id(DISPID_SRGReset)]
    HRESULT Reset([in, defaultvalue(0)] SpeechLanguageId language);

    [id(DISPID_SRGCmdLoadFromFile)]
    HRESULT CmdLoadFromFile([in] const BSTR filename, [in, defaultvalue(SLOStatic)] SpeechLoadOption option);

    [id(DISPID_SRGCmdLoadFromObject)]
    HRESULT CmdLoadFromObject([in]const BSTR classid, [in] const BSTR grammarname, [in, defaultvalue(SLOStatic)] SpeechLoadOption option);

    [id(DISPID_SRGCmdLoadFromResource)]
    HRESULT CmdLoadFromResource([in]long mod, [in] VARIANT name, [in] VARIANT type, [in] SpeechLanguageId language,
            [in, defaultvalue(SLOStatic)] SpeechLoadOption option);

    [id(DISPID_SRGCmdLoadFromMemory)]
    HRESULT CmdLoadFromMemory([in] VARIANT data, [in, defaultvalue(SLOStatic)] SpeechLoadOption option);

    [id(DISPID_SRGCmdLoadFromProprietaryGrammar)]
    HRESULT CmdLoadFromProprietaryGrammar([in] const BSTR guid, [in] const BSTR string, [in] VARIANT data,
                    [in, defaultvalue(SLOStatic)] SpeechLoadOption option);

    [id(DISPID_SRGCmdSetRuleState)]
    HRESULT CmdSetRuleState([in] const BSTR name, [in] SpeechRuleState state);

    [id(DISPID_SRGCmdSetRuleIdState)]
    HRESULT CmdSetRuleIdState([in] long rule, [in] SpeechRuleState State);

    [id(DISPID_SRGDictationLoad)]
    HRESULT DictationLoad([in, defaultvalue("")] const BSTR topic, [in, defaultvalue(SLOStatic)] SpeechLoadOption option);

    [id(DISPID_SRGDictationUnload)]
    HRESULT DictationUnload(void);

    [id(DISPID_SRGDictationSetState)]
    HRESULT DictationSetState([in] SpeechRuleState State);

    [id(DISPID_SRGSetWordSequenceData)]
    HRESULT SetWordSequenceData([in] const BSTR text, [in] long length, [in] ISpeechTextSelectionInformation *info);

    [id(DISPID_SRGSetTextSelection)]
    HRESULT SetTextSelection([in] ISpeechTextSelectionInformation *info);

    [id(DISPID_SRGIsPronounceable)]
    HRESULT IsPronounceable([in] const BSTR word, [out, retval] SpeechWordPronounceable *pronounceable);
}

[
    object,
    uuid(580aa49d-7e1e-4809-b8e2-57da806104b8),
    dual,
    pointer_default(unique)
]
interface ISpeechRecoContext : IDispatch
{
    [propget, id(DISPID_SRCRecognizer)]
    HRESULT Recognizer([out,retval] ISpeechRecognizer **recognizer);

    [propget, id(DISPID_SRCAudioInInterferenceStatus)]
    HRESULT AudioInputInterferenceStatus([out,retval] SpeechInterference *interference);

    [propget, id(DISPID_SRCRequestedUIType)]
    HRESULT RequestedUIType([out,retval] BSTR *type );

    [propputref, id(DISPID_SRCVoice)]
    HRESULT Voice([in] ISpeechVoice *voice);
    [propget, id(DISPID_SRCVoice)]
    HRESULT Voice([out,retval] ISpeechVoice **voice);

    [propput, hidden, id(DISPID_SRAllowVoiceFormatMatchingOnNextSet)]
    HRESULT AllowVoiceFormatMatchingOnNextSet([in] VARIANT_BOOL allow);
    [propget, hidden, id(DISPID_SRAllowVoiceFormatMatchingOnNextSet)]
    HRESULT AllowVoiceFormatMatchingOnNextSet([out,retval] VARIANT_BOOL *allow);

    [propput, id(DISPID_SRCVoicePurgeEvent)]
    HRESULT VoicePurgeEvent([in] SpeechRecoEvents interest);
    [propget, id(DISPID_SRCVoicePurgeEvent)]
    HRESULT VoicePurgeEvent([out,retval] SpeechRecoEvents *interest);

    [propput, id(DISPID_SRCEventInterests)]
    HRESULT EventInterests([in] SpeechRecoEvents interest);
    [propget, id(DISPID_SRCEventInterests)]
    HRESULT EventInterests([out,retval] SpeechRecoEvents *interest);

    [propput, id(DISPID_SRCCmdMaxAlternates)]
    HRESULT CmdMaxAlternates([in] long alternates);
    [propget, id(DISPID_SRCCmdMaxAlternates)]
    HRESULT CmdMaxAlternates([out,retval] long *alternates);

    [propput, id(DISPID_SRCState)]
    HRESULT State([in] SpeechRecoContextState state);
    [propget, id(DISPID_SRCState)]
    HRESULT State([out,retval] SpeechRecoContextState *state);

    [propput, id(DISPID_SRCRetainedAudio)]
    HRESULT RetainedAudio([in] SpeechRetainedAudioOptions option);
    [propget, id(DISPID_SRCRetainedAudio)]
    HRESULT RetainedAudio([out,retval] SpeechRetainedAudioOptions *option);

    [propputref, id(DISPID_SRCRetainedAudioFormat)]
    HRESULT RetainedAudioFormat([in] ISpeechAudioFormat *format);
    [propget, id(DISPID_SRCRetainedAudioFormat)]
    HRESULT RetainedAudioFormat([out,retval] ISpeechAudioFormat **format);

    [id(DISPID_SRCPause)]
    HRESULT Pause(void);

    [id(DISPID_SRCResume)]
    HRESULT Resume(void);

    [id(DISPID_SRCCreateGrammar)]
    HRESULT CreateGrammar([in, defaultvalue(0)] VARIANT id, [out,retval] ISpeechRecoGrammar **grammar);

    [id(DISPID_SRCCreateResultFromMemory)]
    HRESULT CreateResultFromMemory([in] VARIANT *block, [out,retval] ISpeechRecoResult **result);

    [id(DISPID_SRCBookmark)]
    HRESULT Bookmark([in] SpeechBookmarkOptions options, [in] VARIANT pos, [in] VARIANT bookmark);

    [id(DISPID_SRCSetAdaptationData)]
    HRESULT SetAdaptationData([in] BSTR adaptation);
}

typedef [hidden] enum DISPID_SpeechRecognizer
{
    DISPID_SRRecognizer = 1,
    DISPID_SRAllowAudioInputFormatChangesOnNextSet,
    DISPID_SRAudioInput,
    DISPID_SRAudioInputStream,
    DISPID_SRIsShared,
    DISPID_SRState,
    DISPID_SRStatus,
    DISPID_SRProfile,
    DISPID_SREmulateRecognition,
    DISPID_SRCreateRecoContext,
    DISPID_SRGetFormat,
    DISPID_SRSetPropertyNumber,
    DISPID_SRGetPropertyNumber,
    DISPID_SRSetPropertyString,
    DISPID_SRGetPropertyString,
    DISPID_SRIsUISupported,
    DISPID_SRDisplayUI,
    DISPID_SRGetRecognizers,
    DISPID_SVGetAudioInputs,
    DISPID_SVGetProfiles
} DISPID_SpeechRecognizer;

[
    object,
    uuid(2d5f1c0c-bd75-4b08-9478-3b11fea2586c),
    dual,
    pointer_default(unique)
]
interface ISpeechRecognizer : IDispatch
{
    [propputref, id(DISPID_SRRecognizer)]
    HRESULT Recognizer([in]ISpeechObjectToken *recognizer);
    [propget, id(DISPID_SRRecognizer)]
    HRESULT Recognizer([out,retval]ISpeechObjectToken **recognizer);

    [propput, hidden, id(DISPID_SRAllowAudioInputFormatChangesOnNextSet)]
    HRESULT AllowAudioInputFormatChangesOnNextSet([in] VARIANT_BOOL allow);
    [propget, hidden, id(DISPID_SRAllowAudioInputFormatChangesOnNextSet)]
    HRESULT AllowAudioInputFormatChangesOnNextSet([out,retval] VARIANT_BOOL *allow);

    [propputref, id(DISPID_SRAudioInput)]
    HRESULT AudioInput([in,defaultvalue(0)] ISpeechObjectToken *input);
    [propget, id(DISPID_SRAudioInput)]
    HRESULT AudioInput([out,retval] ISpeechObjectToken **input);

    [propputref, id(DISPID_SRAudioInputStream)]
    HRESULT AudioInputStream([in,defaultvalue(0)] ISpeechBaseStream *input);
    [propget, id(DISPID_SRAudioInputStream)]
    HRESULT AudioInputStream([out,retval] ISpeechBaseStream **input);

    [propget, id(DISPID_SRIsShared)]
    HRESULT IsShared([out,retval] VARIANT_BOOL *shared);

    [propput, id(DISPID_SRState)]
    HRESULT State([in] SpeechRecognizerState state);
    [propget, id(DISPID_SRState)]
    HRESULT State([out,retval] SpeechRecognizerState *state);

    [propget, id(DISPID_SRStatus)]
    HRESULT Status([out,retval] ISpeechRecognizerStatus **status);

    [propputref, id(DISPID_SRProfile)]
    HRESULT Profile([in,defaultvalue(0)] ISpeechObjectToken *profile);
    [propget, id(DISPID_SRProfile)]
    HRESULT Profile([out,retval] ISpeechObjectToken **profile);

    [id(DISPID_SREmulateRecognition)]
    HRESULT EmulateRecognition([in] VARIANT elements, [in, defaultvalue(NULL)] VARIANT *attributes,
                                [in, defaultvalue(0)] long id);

    [id(DISPID_SRCreateRecoContext)]
    HRESULT CreateRecoContext([out,retval] ISpeechRecoContext **ncontext);

    [id(DISPID_SRGetFormat)]
    HRESULT GetFormat([in] SpeechFormatType speechtype, [out,retval] ISpeechAudioFormat **audioformat);

    [hidden, id(DISPID_SRSetPropertyNumber)]
    HRESULT SetPropertyNumber([in] const BSTR name, [in] long value, [out,retval] VARIANT_BOOL *supported);

    [hidden, id(DISPID_SRGetPropertyNumber)]
    HRESULT GetPropertyNumber([in] const BSTR name, [in,out] long *value, [out,retval] VARIANT_BOOL *supported);

    [hidden, id(DISPID_SRSetPropertyString)]
    HRESULT SetPropertyString([in] const BSTR name, [in] const BSTR value, [out,retval] VARIANT_BOOL *supported);

    [hidden, id(DISPID_SRGetPropertyString)]
    HRESULT GetPropertyString([in] const BSTR name, [in,out] BSTR *value, [out,retval] VARIANT_BOOL *supported);

    [id(DISPID_SRIsUISupported)]
    HRESULT IsUISupported([in] const BSTR type, [in, defaultvalue(NULL)] const VARIANT *data,
                          [out,retval] VARIANT_BOOL *supported);

    [id(DISPID_SRDisplayUI)]
    HRESULT DisplayUI( [in] long hWnd, [in] BSTR title, [in] const BSTR type, [in, defaultvalue(NULL)] const VARIANT *data);

    [id(DISPID_SRGetRecognizers)]
    HRESULT GetRecognizers([in, defaultvalue("")] BSTR required, [in, defaultvalue("")] BSTR optional,
                                [out,retval] ISpeechObjectTokens **tokens);

    [id(DISPID_SVGetAudioInputs)]
    HRESULT GetAudioInputs([in, defaultvalue("")] BSTR required,  [in, defaultvalue("")] BSTR optional,
                                [out,retval] ISpeechObjectTokens **tokens);

    [id(DISPID_SVGetProfiles)]
    HRESULT GetProfiles([in, defaultvalue("")] BSTR required,  [in, defaultvalue("")] BSTR optional,
                                [out,retval] ISpeechObjectTokens **tokens);

}

typedef enum SpeechStreamFileMode
{
    SSFMOpenForRead = SPFM_OPEN_READONLY,
    SSFMOpenReadWrite = SPFM_OPEN_READWRITE,
    SSFMCreate = SPFM_CREATE,
    SSFMCreateForWrite = SPFM_CREATE_ALWAYS,
} SpeechStreamFileMode;

typedef [hidden] enum DISPID_SpeechFileStream
{
    DISPID_SFSOpen = 100,
    DISPID_SFSClose
} DISPID_SpeechFileStream;

[
    object,
    uuid(af67f125-ab39-4e93-b4a2-cc2e66e182a7),
    dual,
    pointer_default(unique)
]
interface ISpeechFileStream : ISpeechBaseStream
{
    [id(DISPID_SFSOpen)]
    HRESULT Open([in] BSTR filename, [in, defaultvalue(SSFMOpenForRead)] SpeechStreamFileMode mode,
                 [in, defaultvalue(0)] VARIANT_BOOL events);
    [id(DISPID_SFSClose)]
    HRESULT Close(void);
};
