Tiago_Mendes 0 Posted February 7, 2019 Report Share Posted February 7, 2019 Boa noite Venho por este meio vos pedir auxilio para fazer um programa que preciso muito de fazer que usa o sistema speach mas eu não sei usa-lo haverá alguém que me possa explicar Link to post Share on other sites
Mikev 1 Posted February 8, 2019 Report Share Posted February 8, 2019 Bom dia, Tens muita informação acerca do System.Speech.. https://code.msdn.microsoft.com/windowsdesktop/Text-to-Speech-Converter-0ed77dd5 https://docs.microsoft.com/en-us/dotnet/api/system.speech.synthesis.speechsynthesizer?view=netframework-4.7.2 etc.. Era mais fácil se colocasses o teu código e no que realmente precisas de ajuda para a malta ajudar.. Se realmente não souberes nada, aconselho-te a fazeres uma busca e tentar ver o que faz, para que serve, onde utilizar... Abraço. C# 😍 Link to post Share on other sites
Tiago_Mendes 0 Posted February 12, 2019 Author Report Share Posted February 12, 2019 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Speech.Recognition; using System.Speech.Synthesis; using System.Diagnostics; namespace WindowsFormsApplication1 { public partial class Form1 : Form { SpeechSynthesizer ss = new SpeechSynthesizer(); PromptBuilder pb = new PromptBuilder(); SpeechRecognitionEngine sre = new SpeechRecognitionEngine(); Choices clist = new Choices(); public Form1() { InitializeComponent(); } void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { switch (e.Result.Text.ToString()) { case "hello": ss.SpeakAsync("hi"); break; case "how are you": ss.SpeakAsync("I'm doing great ,what about you"); break; case "what is the current time": ss.SpeakAsync("current time is " + DateTime.Now.ToLongTimeString()); break; case "thank you": ss.SpeakAsync("pleasure is mine"); break; case "open chrome": Process.Start("chrome", "https://www.google.pt/"); break; case "close": Application.Exit(); break; } textBox1.Text += e.Result.Text.ToString() + Environment.NewLine; } private void button1_Click_1(object sender, EventArgs e) { //start button click button1.Enabled = false; button2.Enabled = true; clist.Add(new string[] { "hello", "how are you", "what is the current time", "open chrome", "thank you", "close" }); Grammar gr = new Grammar(new GrammarBuilder(clist)); try { sre.RequestRecognizerUpdate(); sre.LoadGrammar(gr); sre.SpeechRecognized += sre_SpeechRecognized; sre.SetInputToDefaultAudioDevice(); sre.RecognizeAsync(RecognizeMode.Multiple); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } } private void button2_Click_1(object sender, EventArgs e) { //butao stop sre.RecognizeAsyncStop(); button1.Enabled = true; button2.Enabled = false; } } } Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now