Beispiel #1
0
        internal static SpeechEvent TryCreateSpeechEvent(ISpEventSource sapiEventSource, bool additionalSapiFeatures, SpeechAudioFormatInfo audioFormat)
        {
            SpeechEvent result = null;
            uint        pulFetched;

            if (additionalSapiFeatures)
            {
                SPEVENTEX pEventArray;
                ((ISpEventSource2)sapiEventSource).GetEventsEx(1u, out pEventArray, out pulFetched);
                if (pulFetched == 1)
                {
                    result = new SpeechEvent(pEventArray);
                }
            }
            else
            {
                SPEVENT pEventArray2;
                sapiEventSource.GetEvents(1u, out pEventArray2, out pulFetched);
                if (pulFetched == 1)
                {
                    result = new SpeechEvent(pEventArray2, audioFormat);
                }
            }
            return(result);
        }
Beispiel #2
0
        // This tries to get an event from the ISpEventSource.
        // If there are no events queued then null is returned.
        // Otherwise a new SpeechEvent is created and returned.
        internal static SpeechEvent TryCreateSpeechEvent(ISpEventSource sapiEventSource, bool additionalSapiFeatures, SpeechAudioFormatInfo audioFormat)
        {
            uint        fetched;
            SpeechEvent speechEvent = null;

            if (additionalSapiFeatures)
            {
                SPEVENTEX sapiEventEx;
                ((ISpEventSource2)sapiEventSource).GetEventsEx(1, out sapiEventEx, out fetched);
                if (fetched == 1)
                {
                    speechEvent = new SpeechEvent(sapiEventEx);
                }
            }
            else
            {
                SPEVENT sapiEvent;
                sapiEventSource.GetEvents(1, out sapiEvent, out fetched);
                if (fetched == 1)
                {
                    speechEvent = new SpeechEvent(sapiEvent, audioFormat);
                }
            }

            return(speechEvent);
        }