using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Speech.Synthesis; using System.Windows.Forms; namespace tts { public partial class Form1 : Form { SpeechSynthesizer speak = new SpeechSynthesizer(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == null) { MessageBox.Show("please! enter some text in box"); } speak.Volume = trackBar2.Value * 10; speak.SelectVoiceByHints(VoiceGender.Male); speak.Rate= trackBar1.Value; speak.Speak(textBox1.Text); } private void button2_Click(object sender, EventArgs e) { speak.Rate = trackBar1.Value; speak.Volume = trackBar2.Value * 10; speak.SelectVoiceByHints(VoiceGender.Female); speak.Speak(textBox1.Text); } private void button3_Click(object sender, EventArgs e) { OpenFileDialog op = new OpenFileDialog(); op.Title = "open a text file"; op.Filter = "text files|*.txt"; op.ShowDialog(); textBox1.Text = File.ReadAllText(op.FileName); } private void button6_Click(object sender, EventArgs e) { SaveFileDialog sv = new SaveFileDialog(); sv.Filter = "wav files|*.wav"; sv.Title = ("save file as .wav"); sv.ShowDialog(); if (sv.ShowDialog() == DialogResult.OK) { speak.SetOutputToWaveFile(sv.FileName); speak.SpeakAsync(textBox1.Text); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)