Ejemplo n.º 1
0
        internal override void Speak(List <TextFragment> frags, byte[] wfx)
        {
            GCHandle gc = GCHandle.Alloc(wfx, GCHandleType.Pinned);

            try
            {
                IntPtr   waveFormat      = gc.AddrOfPinnedObject();
                GCHandle spvTextFragment = new();

                if (ConvertTextFrag.ToSapi(frags, ref spvTextFragment))
                {
                    Guid formatId = SAPIGuids.SPDFID_WaveFormatEx;
                    try
                    {
                        _sapiEngine.Speak(0, ref formatId, waveFormat, spvTextFragment.AddrOfPinnedObject(), _iSite);
                    }
                    finally
                    {
                        ConvertTextFrag.FreeTextSegment(ref spvTextFragment);
                    }
                }
            }
            finally
            {
                gc.Free();
            }
        }
Ejemplo n.º 2
0
        internal override void Speak(List <TextFragment> frags, byte[] wfx)
        {
            GCHandle gCHandle = GCHandle.Alloc(wfx, GCHandleType.Pinned);

            try
            {
                IntPtr   pWaveFormatEx = gCHandle.AddrOfPinnedObject();
                GCHandle sapiFragLast  = default(GCHandle);
                if (ConvertTextFrag.ToSapi(frags, ref sapiFragLast))
                {
                    Guid rguidFormatId = SAPIGuids.SPDFID_WaveFormatEx;
                    try
                    {
                        _sapiEngine.Speak(SPEAKFLAGS.SPF_DEFAULT, ref rguidFormatId, pWaveFormatEx, sapiFragLast.AddrOfPinnedObject(), _iSite);
                    }
                    finally
                    {
                        ConvertTextFrag.FreeTextSegment(ref sapiFragLast);
                    }
                }
            }
            finally
            {
                gCHandle.Free();
            }
        }