Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Speech.Synthesis;
- namespace TTS
- {
- public class StartUp
- {
- private static string message = "Enter text to be read or press Esc to exit";
- private static string volumeMessage = "Enter volume from 0 to 100";
- private static string speechSpeedMessage = "Enter speech speed from -10 to 10";
- public static void Main()
- {
- while (true)
- {
- Console.WriteLine(message);
- if (Console.ReadKey().Key == ConsoleKey.Escape)
- {
- break;
- }
- string text = Console.ReadLine();
- Console.WriteLine(volumeMessage);
- int volume = int.Parse(Console.ReadLine());
- Console.WriteLine(speechSpeedMessage);
- int speechSpeed = int.Parse(Console.ReadLine());
- using (SpeechSynthesizer synth = new SpeechSynthesizer())
- {
- synth.SetOutputToDefaultAudioDevice();
- synth.Rate = speechSpeed;
- synth.Volume = volume;
- synth.Speak(text);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment