Esempio n. 1
0
        private void SendFile(object obj)
        {
            Connection       c      = (Connection)obj;
            ConnectionStream stream = new ConnectionStream(c);

            using (FileStream fs = File.OpenRead(_answerSoundFileName)) {
                using (ConnectionWriter writer = new ConnectionWriter(stream)) {
                    writer.Write(fs);
                }
            }
        }
Esempio n. 2
0
        private void SendTextToSpeech(object obj)
        {
            Connection        c      = (Connection)obj;
            ConnectionStream  stream = new ConnectionStream(c);
            SpeechSynthesizer s      = new SpeechSynthesizer();

            using (MemoryStream memStream = new MemoryStream()) {
                s.SetOutputToAudioStream(memStream, new SpeechAudioFormatInfo(EncodingFormat.ALaw,
                                                                              8000, 8, 1, 8000, 1, null));
                s.Speak(_textToSpeak);
                memStream.Seek(0, SeekOrigin.Begin);

                using (ConnectionWriter writer = new ConnectionWriter(stream)) {
                    writer.Reverse = true;
                    writer.Write(memStream);
                }
            }
        }
Esempio n. 3
0
 private void SendFile(object obj) {
     Connection c = (Connection)obj;
     ConnectionStream stream = new ConnectionStream(c);
     using (FileStream fs = File.OpenRead(_answerSoundFileName)) {
         using (ConnectionWriter writer = new ConnectionWriter(stream)) {
             writer.Write(fs);
         }
     }
 }
Esempio n. 4
0
        private void SendTextToSpeech(object obj) {
            Connection c = (Connection)obj;
            ConnectionStream stream = new ConnectionStream(c);
            SpeechSynthesizer s = new SpeechSynthesizer();
            using (MemoryStream memStream = new MemoryStream()) {
                s.SetOutputToAudioStream(memStream, new SpeechAudioFormatInfo(EncodingFormat.ALaw,
                    8000, 8, 1, 8000, 1, null));
                s.Speak(_textToSpeak);
                memStream.Seek(0, SeekOrigin.Begin);

                using (ConnectionWriter writer = new ConnectionWriter(stream)) {
                    writer.Reverse = true;
                    writer.Write(memStream);
                }
            }
        }