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
 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());
             }
         }
     }
 }