Advertisement
hackthecode

Speech.Synthesis System.IO.File.ReadAllText

Oct 30th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. using System.Speech.Synthesis;
  3. using System.Text;
  4.  
  5. namespace test
  6. {
  7.     static class HelloWorld
  8.     {
  9.         static void Main()
  10.         {
  11.             Console.OutputEncoding = Encoding.UTF8;
  12.             string text = System.IO.File.ReadAllText("C:\\Users\\HackTheCode\\Documents\\visual studio 2015\\Projects\\HelloCSharp\\test\\text.txt"); // <- add your text file here
  13.             Console.WriteLine(text);
  14.  
  15.             SpeechSynthesizer synth = new SpeechSynthesizer();
  16.             synth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Senior);
  17.             synth.SetOutputToDefaultAudioDevice();
  18.             synth.Speak(text);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement