Beispiel #1
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;            //quick and dirty error handling :)
            _server = new LyncServer();
            var t = _server.Start();

            _server.IncomingCall       += server_IncomingCall;
            _server.IncomingConference += _server_IncomingConference;

            var cancellationToken = new CancellationToken();

            _speech = new SpeechEngine(cancellationToken);

            _speech.Disconnected += _speech_Disconnected;
            _speech.Failed       += _speech_Failed;

            var authenticated = _speech.Authenticate().Result;

            if (authenticated)
            {
                _speech.Connect().Wait();
            }

            Console.WriteLine("Press any key to stop server and exit");
            Console.ReadLine();
            _server.Stop().Wait();
        }
        public void Start(AudioVideoFlow flow, LyncServer server)
        {
            _flow   = flow;
            _server = server;

            Recorder recorder = new Recorder();

            recorder.AttachFlow(_flow);
            WmaFileSink sink = new WmaFileSink("voice_input.wma");

            recorder.SetSink(sink);
            recorder.Start();

            var        wmafileReader = new WMAFileReader("voice_input.wma");
            WaveStream waveStream    = WaveFormatConversionStream.CreatePcmStream(wmafileReader);
            int        reader        = 0;

            byte[] buffer = new byte[4096];
            var    header = GetWaveHeader(waveStream.WaveFormat);

            _speech.SendMessage(new ArraySegment <byte>(header, 0, header.Length));

            while ((reader = waveStream.Read(buffer, 0, buffer.Length)) != 0)
            {
                AudioDataAvailable(new ArraySegment <byte>(buffer, 0, buffer.Length));
                Thread.Sleep(10);
            }
        }