private void TrkSpeechRate_Scroll(object sender, EventArgs e) { synthSAPI.SpeakAsyncCancelAll(); int val = trkSpeechRate.Value; synthSAPI.SpeakAsync("rate " + val); val = val - 10; Properties.Settings.Default.SAPISpeechRate = val; synthSAPI.Rate = val; }
/// <summary> /// Speak the image description. /// </summary> /// <param name="description">The image description to speak.</param> private async Task SpeakDescription(string description) { // set up an adult female voice synthesizer var synth = new System.Speech.Synthesis.SpeechSynthesizer(); synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult); // speak the description using the builtin synthesizer await Task.Run(() => { synth.SpeakAsync(description); }); }
private void speak(bool bAsync, System.Speech.Synthesis.PromptBuilder pb) { try { if (bSaveFile) { ss.SetOutputToNull(); delOutFile(); ss.SetOutputToWaveFile(strOutputFile); } if (bAsync) { ss.SpeakAsync(pb); } else { ss.Speak(pb); } } catch (Exception ex) { speak("An error occured:" + ex.Message, false); } }
private void SetCurrentText(TextBlock textBlock, string text) { this.Dispatcher.Invoke(() => { textBlock.Text = text; if (textBlock.Text == "What's the weather like?") { customModelCurrentText.Text = "The weather is hot"; // Initialize a new instance of the SpeechSynthesizer. System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer(); // Configure the audio output. synth.SetOutputToDefaultAudioDevice(); // Speak a string asynchronously. synth.SpeakAsync("The weather is hot"); } else if (textBlock.Text == "What is the best University?") { customModelCurrentText.Text = "It's National Central University!"; // Initialize a new instance of the SpeechSynthesizer. System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer(); // Configure the audio output. synth.SetOutputToDefaultAudioDevice(); // Speak a string asynchronously. synth.SpeakAsync("It's National Central University!"); } else if (textBlock.Text == "What is your name?") { customModelCurrentText.Text = "My name is Vando"; // Initialize a new instance of the SpeechSynthesizer. System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer(); // Configure the audio output. synth.SetOutputToDefaultAudioDevice(); // Speak a string asynchronously. synth.SpeakAsync("My name is Vando"); } else { customModelCurrentText.Text = "....???"; } }); }
static void Main(string[] args) { System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer(); List <InstalledVoice> voices = new List <InstalledVoice>(); voices.AddRange(synth.GetInstalledVoices(new CultureInfo("en-GB"))); voices.AddRange(synth.GetInstalledVoices(new CultureInfo("en-US"))); // synth.Voice. synth.SpeakAsync(@"one two three blarg! Shoe shop event horizon. bannana puding to the nth degree poisoning pigeons in the park"); Console.Read(); synth.SpeakAsyncCancelAll(); }
private void buttonRead_Click(object sender, EventArgs e) { var text = richTextBox1.SelectedText; if (string.IsNullOrEmpty(text)) { text = richTextBox1.Text; if (checkBoxFromCursor.Checked) { text = text.Substring(richTextBox1.SelectionStart, text.Length - richTextBox1.SelectionStart); } } if (string.IsNullOrEmpty(text)) { MessageBox.Show("No text selected", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { _synth.Rate = trackBar1.Value; _synth.SelectVoice(comboBoxVoices.Text.Split('#')[0]); _prompt = _synth.SpeakAsync(text); } }
private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { // Speech utterance confidence below which we treat speech as if it hadn't been heard Console.WriteLine("Inside speechrecognized event"); const double ConfidenceThreshold = 0.3; if (e.Result.Confidence >= ConfidenceThreshold) { Console.WriteLine(e.Result.Confidence); switch (e.Result.Semantics.Value.ToString()) { case "FORWARD": sp.WriteLine("256"); sp.WriteLine("170"); Console.WriteLine(e.Result.Text); Console.WriteLine("*************LEFT**************"); if (spflagl == true) { speaker.SpeakAsync("I'm sorry, it is on"); } else { // speaker.SpeakAsync("I have switched on the left L E D"); speaker.SpeakAsync("Done"); spflagl = true; } break; case "BACKWARD": sp.WriteLine("257"); sp.WriteLine("170"); Console.WriteLine("*************RIGHT**************"); if (spflagr == true) { //speaker.SpeakAsync("I'm sorry, it is on"); speaker.SpeakAsync("Done"); } else { //speaker.SpeakAsync("I have switched on the right L E D"); speaker.SpeakAsync("Done"); spflagr = true; } break; case "LEFT": sp.WriteLine("500"); if (spflagl == true || spflagr == true) { spflagl = false; spflagr = false; // speaker.SpeakAsync("Switching off the LEDs"); speaker.SpeakAsync("Done"); } break; case "RIGHTLOW": sp.WriteLine("257"); sp.WriteLine("84"); spflagr = true; //speaker.SpeakAsync("Decreased brightness of the right L E D"); speaker.SpeakAsync("Done"); break; case "RIGHTHIGH": sp.WriteLine("257"); sp.WriteLine("255"); spflagr = true; // speaker.SpeakAsync("increased brightness of the right L E D"); speaker.SpeakAsync("Done"); break; case "LEFTLOW": sp.WriteLine("256"); sp.WriteLine("84"); spflagl = true; // speaker.SpeakAsync("Decreased brightness of the left L E D"); speaker.SpeakAsync("Done"); break; case "LEFTHIGH": sp.WriteLine("256"); sp.WriteLine("255"); spflagl = true; speaker.SpeakAsync("Done"); //speaker.SpeakAsync("Increased brightness of the left L E D"); break; case "BOTH_ON": Console.Write("Both on"); Console.WriteLine(e.Result.Text); if (spflagl == true && spflagr == true) { speaker.SpeakAsync("Already on"); } { sp.WriteLine("256"); sp.WriteLine("255"); sp.WriteLine("257"); sp.WriteLine("255"); speaker.SpeakAsync("Done"); } break; } } }
private void SendSpeechRequest(output_data data) { WebClient webClient = new WebClient(); webClient.QueryString.Add("query", data.query); webClient.QueryString.Add("uid", data.uid); webClient.QueryString.Add("reset", data.reset); string result = webClient.DownloadString("http://marko-backend.herokuapp.com/handle_voice"); synth.SpeechSynthesizer synthesizer = new synth.SpeechSynthesizer(); synthesizer.SpeakAsync(result); }
public void read_aloud_html(string inHtml, string audir, string voicename, int startID) { try { System.Speech.Synthesis.SpeechSynthesizer l_spv = new System.Speech.Synthesis.SpeechSynthesizer(); l_spv.SpeakCompleted += new EventHandler <System.Speech.Synthesis.SpeakCompletedEventArgs>(spv_SpeakCompleted); l_spv.SpeakProgress += new EventHandler <System.Speech.Synthesis.SpeakProgressEventArgs>(spv_SpeakProgress); l_spv.SelectVoice(voicename); l_spv.Rate = -2; l_spv.SetOutputToWaveFile(audir + "\\audio.wav"); audioComplete = false; spanTxt = ""; smilTxt = ""; last_time = ""; curFullTxt = ""; curFullTxt = inHtml; spanID = startID; spanPoint = 0; curPageHtml = "page.html"; curaudioFile = "audio.mp3"; probar.Visible = true; probar.Maximum = Regex.Matches(inHtml, "\\s").Count; probar.Value = 0; l_spv.SpeakAsync(inHtml); while (audioComplete == false) { Application.DoEvents(); } string wSmil = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; wSmil += "<smil xmlns=\"http://www.w3.org/ns/SMIL\" version=\"3.0\" profile=\"http://www.idpf.org/epub/30/profile/content/\">\n"; wSmil += "<body>\n"; wSmil += smilTxt; wSmil += "\n</body></smil>\n"; txt_smil.Text = wSmil; txt_out.Text = htLineTxt; // File.WriteAllText(htmlDir + "\\page" + pgNum + ".smil", wSmil); probar.Visible = false; l_spv.Dispose(); //write mp3 file convert_mp3(audir); if (File.Exists(txt_savefile.Text)) { File.Delete(txt_savefile.Text); } File.Copy(audir + "\\audio.mp3", txt_savefile.Text, true); gCls.show_message("SMIL Tag generated successfully"); } catch (Exception erd) { gCls.show_error(erd.Message.ToString()); return; } }
public void Recengine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { string Speech = e.Result.Text; switch (e.Result.Text) { case "Hello": case "Hi": int randomi = random.Next(1, 3); if (randomi == 1) { synthesizer.SpeakAsync("hello my creator"); richTextBox1.Text += "\nhello my creator"; break; } else if (randomi == 2) { synthesizer.SpeakAsync("hello my creator, did you have a nice day"); richTextBox1.Text += "\nhello my creator, did you have a nice day"; break; } else { synthesizer.SpeakAsync("hello my creator, how are you"); richTextBox1.Text += "\nhello my creator, how are you"; break; } case "open youtube": synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; System.Diagnostics.Process.Start("https://www.youtube.com"); break; case "open firefox": try { TextReader file = new StreamReader(@"F:\jarvispath\firefoxpath.txt"); firefoxpath = file.ReadLine(); synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; //MessageBox.Show(settings.firefox); System.Diagnostics.Process.Start(firefoxpath); break; }catch (InvalidOperationException inv) { synthesizer.SpeakAsync("error"); richTextBox1.Text += "\nerror"; break; } case "open skype": try { TextReader skype = new StreamReader(@"F:\jarvispath\skypepath.txt"); skypepath = skype.ReadLine(); synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; System.Diagnostics.Process.Start(skypepath); break; }catch (InvalidOperationException skyperror) { synthesizer.SpeakAsync("error"); richTextBox1.Text += "\nerror"; break; } case "open origin": try { TextReader origin = new StreamReader(@"F:\jarvispath\originpath.txt"); originpath = origin.ReadLine(); synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; System.Diagnostics.Process.Start(originpath); break; } catch (InvalidOperationException originerror) { synthesizer.SpeakAsync("error"); richTextBox1.Text += "\nerror"; break; } case "open facebook": synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; System.Diagnostics.Process.Start("https://www.facebook.com/"); break; case "what time is it": DateTime now = System.DateTime.Now; string time = now.GetDateTimeFormats('t')[0]; synthesizer.SpeakAsync(time); richTextBox1.Text += "\n"; richTextBox1.Text += time; break; case "open hacker news": synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; System.Diagnostics.Process.Start("http://thehackernews.com/"); break; case "exit": this.Close(); break; case "speak selected text": synthesizer.SpeakAsync(richTextBox1.SelectedText); break; case "open code": synthesizer.SpeakAsync("you are going to make me better?"); richTextBox1.Text += "\nyou are going to make me better?"; System.Diagnostics.Process.Start(@"F:\jarvis\jarvis.sln"); break; case "open reddit": synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; System.Diagnostics.Process.Start("https://www.reddit.com/r/security"); break; case "show commands": System.Diagnostics.Process.Start(@"F:\choices.txt"); break; case "open command line": synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; System.Diagnostics.Process.Start("cmd.exe"); break; case "open notepad": synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; System.Diagnostics.Process.Start("notepad"); break; case "go away": if (this.WindowState != FormWindowState.Minimized) { this.WindowState = FormWindowState.Minimized; } break; case "disable": recengine.RecognizeAsyncStop(); button1.Enabled = true; button2.Enabled = false; synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; break; case "come back": if (this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; } break; case "open safe mail": System.Diagnostics.Process.Start("https://orange.safe-mail.net/cgi-bin/Safe-mail.net/gate/N1O-568a7110-3f67b389"); synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; break; case "take screenshot": Form.ActiveForm.Opacity = 0; Graphics gb = Graphics.FromImage(bg as Image); gb.CopyFromScreen(0, 0, 0, 0, bg.Size); Form.ActiveForm.Opacity = 100; synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; saveFileDialog2.Filter = "jpeg image|*.jpg"; saveFileDialog2.ShowDialog(); bg.Save(saveFileDialog2.FileName); synthesizer.SpeakAsync("yes sir"); richTextBox1.Text += "\nyes sir"; Form3 fmr3 = new Form3(); fmr3.Show(); break; case "etsi": string query = Speech.Replace("etsi", e.Result.Text); query = System.Web.HttpUtility.UrlEncode(query); string url = "https://www.google.com/search?q=" + e.Result.Text; System.Diagnostics.Process.Start(url); break; default: break; } }
// <----------------database comms----------------> private int submit(String query) { // 2 = individual id ; 1 = family id ; 0 = other, should be name int queryType = DbHelper.classify(query); // Get things from the database, which // Stores result in the SearchHelper Data Table of DbHelper class. /*if (queryType == 2) // Query is an individual id * { * DbHelper.searchByIdForIndividuals(query.Replace(" ", "").Replace("%", "")); * }*/ if (queryType == 1) // Query is a family id { DbHelper.searchByIdForFamilies(query.Replace(" ", "")); } if (queryType == 0) // Query is a name { String[] queries = query.Split(' '); DataTable result = null; foreach (String q in queries) { if (q == "") { continue; } DataTable toAdd = DbHelper.searchByName(q); if (result == null) { result = toAdd; } else { result.Merge(toAdd); } } result = DbHelper.RemoveDupes(result); if (result == null) { result = new DataTable(); } DbHelper.copyToSearchHelper(result); } DataTable table = DbHelper.SearchHelper; if (table == null) { return(-1); } int numberOfRowsInQueryResult = table.Rows.Count; Family selectedMember = getMemberSelection(numberOfRowsInQueryResult); if (selectedMember != null) { selectedMember.LoginTime = DateTime.Now; viewModel.Login(selectedMember); viewModel.ForceUpdateHistoryReportTextCommand.Execute(null); // show installed voices foreach (var v in speaker.GetInstalledVoices().Select(v => v.VoiceInfo)) { Console.WriteLine("Name:{0}, Gender:{1}, Age:{2}", v.Description, v.Gender, v.Age); } speaker.SpeakAsync(selectedMember.Greeting); return(1); } if (selectedMember == null) { /*if (numberOfRowsInQueryResult > 0) // User cancelled * { * db.DoDisplayError = true; * db.ErrorMessage = "Cancelled"; * db.ErrorDisplayRule = "TextChanged"; * * db.ForceValidateCommand.Execute(null); * }*/ if (numberOfRowsInQueryResult == 0) // Search returned no results { if (LoginViewModel.DoDisplayError != true) // if Error not already set in DbHelper due to unavailability of database file { LoginViewModel.DoDisplayError = true; LoginViewModel.ErrorMessage = "No members match the criteria"; LoginViewModel.ErrorDisplayRule = "TextChanged"; viewModel.ForceValidateCommand.Execute(null); } } } return(-1); }
private void button29_Click(object sender, EventArgs e) { var synth = new System.Speech.Synthesis.SpeechSynthesizer(); synth.SpeakAsync("Kilo"); }
private void button37_Click(object sender, EventArgs e) { if (textBox1.Text != null) { var synth = new System.Speech.Synthesis.SpeechSynthesizer(); for (int i = 0; i < textBox1.Text.Length; i++) { if (textBox1.Text.ElementAt(i) == 'A') { synth.SpeakAsync("Alpha"); } if (textBox1.Text.ElementAt(i) == 'B') { synth.SpeakAsync("Bravo"); } if (textBox1.Text.ElementAt(i) == 'C') { synth.SpeakAsync("Charlie"); } if (textBox1.Text.ElementAt(i) == 'D') { synth.SpeakAsync("Deltah"); } if (textBox1.Text.ElementAt(i) == 'E') { synth.SpeakAsync("Echo"); } if (textBox1.Text.ElementAt(i) == 'F') { synth.SpeakAsync("Foxtrot"); } if (textBox1.Text.ElementAt(i) == 'G') { synth.SpeakAsync("Golf"); } if (textBox1.Text.ElementAt(i) == 'H') { synth.SpeakAsync("Hotel"); } if (textBox1.Text.ElementAt(i) == 'I') { synth.SpeakAsync("India"); } if (textBox1.Text.ElementAt(i) == 'J') { synth.SpeakAsync("Juliett"); } if (textBox1.Text.ElementAt(i) == 'K') { synth.SpeakAsync("Kilo"); } if (textBox1.Text.ElementAt(i) == 'L') { synth.SpeakAsync("Lima"); } if (textBox1.Text.ElementAt(i) == 'M') { synth.SpeakAsync("Mike"); } if (textBox1.Text.ElementAt(i) == 'N') { synth.SpeakAsync("November"); } if (textBox1.Text.ElementAt(i) == 'O') { synth.SpeakAsync("Oscar"); } if (textBox1.Text.ElementAt(i) == 'P') { synth.SpeakAsync("Papa"); } if (textBox1.Text.ElementAt(i) == 'R') { synth.SpeakAsync("Romeo"); } if (textBox1.Text.ElementAt(i) == 'S') { synth.SpeakAsync("Sierra"); } if (textBox1.Text.ElementAt(i) == 'T') { synth.SpeakAsync("Tango"); } if (textBox1.Text.ElementAt(i) == 'U') { synth.SpeakAsync("Uniform"); } if (textBox1.Text.ElementAt(i) == 'V') { synth.SpeakAsync("Victor"); } if (textBox1.Text.ElementAt(i) == 'W') { synth.SpeakAsync("Whiskey"); } if (textBox1.Text.ElementAt(i) == 'Y') { synth.SpeakAsync("Yankee"); } if (textBox1.Text.ElementAt(i) == 'Z') { synth.SpeakAsync("Zulu"); } if (textBox1.Text.ElementAt(i) == '1') { synth.SpeakAsync("One"); } if (textBox1.Text.ElementAt(i) == '2') { synth.SpeakAsync("Two"); } if (textBox1.Text.ElementAt(i) == '3') { synth.SpeakAsync("Three"); } if (textBox1.Text.ElementAt(i) == '4') { synth.SpeakAsync("Four"); } if (textBox1.Text.ElementAt(i) == '5') { synth.SpeakAsync("Five"); } if (textBox1.Text.ElementAt(i) == '6') { synth.SpeakAsync("Six"); } if (textBox1.Text.ElementAt(i) == '7') { synth.SpeakAsync("Seven"); } if (textBox1.Text.ElementAt(i) == '8') { synth.SpeakAsync("Eight"); } if (textBox1.Text.ElementAt(i) == '9') { synth.SpeakAsync("Niner"); } if (textBox1.Text.ElementAt(i) == '0') { synth.SpeakAsync("Zero"); } Thread.Sleep(375); } } }