private static byte[] StartSpeak(string word) { var ms = new MemoryStream(); using (System.Speech.Synthesis.SpeechSynthesizer synhesizer = new System.Speech.Synthesis.SpeechSynthesizer()) { foreach (var voice in synhesizer.GetInstalledVoices()) { Console.WriteLine("select(y/n): " + voice.VoiceInfo.Name); var key = Console.ReadKey(); if (key.Key == ConsoleKey.Y) { synhesizer.SelectVoice(voice.VoiceInfo.Name); synhesizer.SelectVoiceByHints(voice.VoiceInfo.Gender, voice.VoiceInfo.Age, 1, voice.VoiceInfo.Culture); synhesizer.SetOutputToWaveStream(ms); synhesizer.Speak(word); } } } return ms.ToArray(); }
protected override void Execute(CodeActivityContext context) { var voice = Voice.Get(context); var rate = Rate.Get(context); var volume = Volume.Get(context); var doasync = Async.Get(context); var text = Text.Get(context); var task = Task.Run(() => { using (var synthesizer = new System.Speech.Synthesis.SpeechSynthesizer()) { if (!string.IsNullOrEmpty(voice)) { synthesizer.SelectVoice(voice); } if (rate >= 1 && rate <= 10) { synthesizer.Rate = rate; } if (volume >= 1 && volume <= 100) { synthesizer.Volume = volume; } synthesizer.SetOutputToDefaultAudioDevice(); synthesizer.Speak(text); } }); if (!doasync) { task.Wait(); } }
void ExcelRead() { synthesizer.Volume = 80; Invoke(new Action(() => { synthesizer.SelectVoice(listBox1.SelectedItem.ToString()); })); for (int i = 1; i >= 0; i++) { Excel.Range B = ex.get_Range("B" + Convert.ToString(i), Missing.Value); Excel.Range C = ex.get_Range("C" + Convert.ToString(i), Missing.Value); if (B.Text != "") { WAVLocationDialog.FileName = B.Text + ".wav"; synthesizer.SetOutputToWaveFile(WAVLocationDialog.FileName, new SpeechAudioFormatInfo(11025, AudioBitsPerSample.Eight, AudioChannel.Mono)); synthesizer.Speak(C.Text); } else { ex.Workbooks.Close(); Environment.Exit(0); } } }
static void Main(string[] args) { var syn = new System.Speech.Synthesis.SpeechSynthesizer(); syn.SelectVoice("Microsoft Server Speech Text to Speech Voice (ja-JP, Haruka)"); syn.Speak("こんにちは"); }
public static void sayt(string h) { try { Console.WriteLine(h); saytd.SelectVoice("Microsoft Hortense Desktop"); saytd.SpeakAsync(h); } catch { } }
public void GetWeather() { say.SelectVoice("Microsoft Hortense Desktop"); var path = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22saguenay%22)%20and%20u%3D%22c%22&format=xml&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"; var doc = XDocument.Load(path); XNamespace ns = "http://xml.weather.yahoo.com/ns/rss/1.0"; var results = (from i in doc.Descendants(ns + "condition") select i); foreach (var thisResult in results) { Console.WriteLine("la temperature {0} pour dehors et il fait {1}", thisResult.Attribute("temp").Value, thisResult.Attribute("text").Value); say.SpeakAsync(string.Format("la temperature {0} pour dehors et il fait {1}", thisResult.Attribute("temp").Value, thisResult.Attribute("text").Value)); } }
//------------------------------------------------------------------------------------------------------------------------------- public void Init() { System.Speech.Synthesis.SpeechSynthesizer mySynth = new System.Speech.Synthesis.SpeechSynthesizer(); var Voices = mySynth.GetInstalledVoices(); for (int count = 0; count < Voices.Count; count++) { if (Voices[count].VoiceInfo.Name.ToLowerInvariant().Contains("hazel")) { mySynth.SelectVoice(Voices[count].VoiceInfo.Name); break; } } m_mainTalker = mySynth; }
private static string generateSpeech(string userid, string condition, string pathResponseFile, string path) { // ********* generate wav file voicing the response ***************** // Using Microsoft voices // initiate new instance of speech synthesizer // needs own separate dedicated thread... string response = readResponse(pathResponseFile); string audioFilePath = ""; SQLLog.InsertLog(DateTime.Now, "Beginning Thread", "Beginning Thread", "ResponseGeneration.moveSpeak", 1); Thread t = new Thread(() => { try { System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer(); string gender = SQLConditionGenderInfo.GetGender(userid); bool makecopy = false; if (synth != null) { if (gender.Contains("female")) { synth.SelectVoice("Microsoft Zira Desktop"); } else { synth.SelectVoice("Microsoft David Desktop"); } if (condition == "nonsocial" || condition == "social") { synth.SetOutputToWaveFile(path + "data\\agentAudio\\transformed.wav"); audioFilePath = "transformed.wav"; makecopy = true; } else { synth.SetOutputToWaveFile(path + "data\\agentAudio\\response.wav"); audioFilePath = "response.wav"; } synth.Speak(response); if (makecopy) { string formatFileName = string.Format("data\\agentAudio\\transformed_{0:yyyy-MM-dd_hh-mm-ss-tt}.wav", DateTime.Now); audioFilePath = string.Format("transformed_{0:yyyy-MM-dd_hh-mm-ss-tt}.wav", DateTime.Now); synth.SetOutputToWaveFile(path + formatFileName); synth.Speak(response); } synth.SetOutputToNull(); } } catch (Exception e) { SQLLog.InsertLog(DateTime.Now, "Something went wrong in generating speech", "", "ResponseGeneration.generateSpeech", 1); } }); t.Start(); t.Join(); Thread.Sleep(1000); return(audioFilePath); }
static void Main(string[] args) { var syn = new System.Speech.Synthesis.SpeechSynthesizer(); syn.SelectVoice("Microsoft Server Speech Text to Speech Voice (ja-JP, Haruka)"); syn.Speak("こんにちは"); }
public static void sayt(string hdgf) { System.Speech.Synthesis.SpeechSynthesizer skdf = new System.Speech.Synthesis.SpeechSynthesizer(); skdf.SelectVoice("Microsoft Hortense Desktop"); skdf.SpeakAsync(hdgf); }