Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 internal void SendNotification(object ignored)
 {
     lock (this)
     {
         if (_sapiEventSourceReference != null)
         {
             ISpEventSource spEventSource = (ISpEventSource)_sapiEventSourceReference.Target;
             if (spEventSource != null)
             {
                 List <SpeechEvent> list = new List <SpeechEvent>();
                 SpeechEvent        item;
                 while ((item = SpeechEvent.TryCreateSpeechEvent(spEventSource, _additionalSapiFeatures, _audioFormat)) != null)
                 {
                     list.Add(item);
                 }
                 _dispatcher.Post(list.ToArray());
             }
         }
     }
 }
Ejemplo n.º 4
0
 internal void SendNotification(object ignored)
 {
     lock (this)
     {
         // Call dispatchEventDelegate for each SAPI event currently queued.
         if (_sapiEventSourceReference != null)
         {
             ISpEventSource sapiEventSource = (ISpEventSource)_sapiEventSourceReference.Target;
             if (sapiEventSource != null)
             {
                 List <SpeechEvent> speechEvents = new();
                 SpeechEvent        speechEvent;
                 while (null != (speechEvent = SpeechEvent.TryCreateSpeechEvent(sapiEventSource, _additionalSapiFeatures, _audioFormat)))
                 {
                     speechEvents.Add(speechEvent);
                 }
                 _dispatcher.Post(speechEvents.ToArray());
             }
         }
     }
 }