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