private void toolStrip3_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { switch (e.ClickedItem.Tag + "") { case "1": if (openFileDialog1.ShowDialog() == DialogResult.OK) { textBox2.Text = File.ReadAllText(openFileDialog1.FileName, Encoding.Default); } break; case "2": if (saveFileDialog1.ShowDialog() == DialogResult.OK) { File.WriteAllText(saveFileDialog1.FileName, textBox2.Text, Encoding.Default); } break; case "3": if (fontDialog1.ShowDialog() == DialogResult.OK) { textBox2.Font = fontDialog1.Font; } break; case "4": SpeechLib.SpVoiceClass sp = new SpeechLib.SpVoiceClass(); sp.Speak(textBox2.Text, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault); break; } }
public void Play() { var synth = new SpeechLib.SpVoiceClass(); var voices = synth.GetVoices("", $"Gender={VoiceGender};Age={VoiceAge};Language={new CultureInfo(CultureInfo).LCID:X}"); synth.Voice = voices.Item(0); synth.Volume = Volume; synth.Rate = Rate; synth.Speak(Text); }
public SpeechHandler() { /*if (File.Exists(Environment.GetEnvironmentVariable("SystemRoot")+@"\Speech\Xvoice.dll")) { * SAPI4Supported = true; * } else { * SAPI4Supported = false; * }*/ voice = new SpeechLib.SpVoiceClass(); tokens = voice.GetVoices("", ""); sd = new SpeakDelegate(voice.Speak); }
/*Reproduce sound. First select whitch kind of Option must to reproduce. * Second will be reproduced each character in CodeSound. */ public void reproduceSound(object sender, EventArgs e) { SpeechLib.SpVoiceClass m_TTS = new SpeechLib.SpVoiceClass(); string codeSound = ""; if (_OptionChoose == "0") { codeSound = _numbers; } if (_OptionChoose == "1") { codeSound = _letters; } if (_OptionChoose == "2") { codeSound = _fullcode.Substring(0, 1).ToString() + _fullcode.Substring(6, 1).ToString(); } if (_OptionChoose == "3") { codeSound = _fullcode.Substring(0, 4).ToString(); } if (_OptionChoose == "4") { codeSound = _fullcode.Substring(4, 3).ToString(); } if (_OptionChoose == "5") { codeSound = _fullcode; } for (int i = 0; i < codeSound.Length; i++) { char codepart = codeSound.Substring(i, 1).ToCharArray()[0]; string UpperLowerCase = ""; if (Char.IsLetter(codepart)) { if (Char.IsUpper(codepart)) { UpperLowerCase = "Upper Case"; } else { UpperLowerCase = "Lower Case"; } m_TTS.Speak(UpperLowerCase, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault); } m_TTS.Speak(codeSound.Substring(i, 1).ToString(), SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync); m_TTS.WaitUntilDone(Timeout.Infinite); //m_TTS.Speak(codeSound.Substring(i, 1).ToString(), SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak); } //Response.Write(""); }