private void PersonIdentifier_Load(object sender, EventArgs e) { faces = new HaarCascade("haarcascade_frontalface_default.xml"); try { string labelsInfo = File.ReadAllText(Application.StartupPath + "/PeopleData/names.txt"); string[] labels = labelsInfo.Split('%'); numLabels = Convert.ToInt16(labels[0]); contTrain = numLabels; string loadFaces; for (int tf = 1; tf < numLabels; tf++) { loadFaces = "face" + tf + ".bmp"; trainningImages.Add(new Image <Gray, byte>(Application.StartupPath + "/PeopleData/" + loadFaces)); Labels.Add(labels[tf]); } } catch (Exception ex) { Speaker.Speak("sem imagens disponíves, não é possível fazer reconhecimento!"); } }
private void MotionDetection_Load(object sender, EventArgs e) { getDevices(); detector = new AForge.Vision.Motion.MotionDetector(new TwoFramesDifferenceDetector(), new MotionBorderHighlighting()); Detect(); Speaker.Speak("detecção de movimento iniciada!"); }
public static void InitializingSystem() { player = new SoundPlayer("Sounds\\jarvis_morning.wav"); Speaker.Speak("bom dia, senhor são " + DateTime.Now.Hour + " horas e " + DateTime.Now.Minute + " minutos "); player.Play(); }
public static void DoCalculation(string calc) { string simple = calc.Replace("quanto é", ""); // remove o início da frase simple = simple.Trim(); // remove espaços em branco string[] parts = simple.Split(' '); // dividi em array de string's double result = 0.0; // resultado do cálculo switch (parts[1]) // casos para a segunda string, ou seja a operação { case "mais": result = Convert.ToDouble(parts[0]) + Convert.ToDouble(parts[2]); // usando casting break; case "menos": result = Convert.ToDouble(parts[0]) - Convert.ToDouble(parts[2]); // usando casting break; case "vezes": result = Convert.ToDouble(parts[0]) * Convert.ToDouble(parts[2]); // usando casting break; case "dividido": result = Convert.ToDouble(parts[0]) / Convert.ToDouble(parts[3]); // usando casting break; case "porcento": result = Convert.ToDouble(parts[0]) * 100 / Convert.ToDouble(parts[3]); // usando casting break; } result = Math.Round(result, 2); Speaker.Speak(result.ToString()); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "" && textBox2.Text != "") { // vamos verificar os tipos de comandos string tagCmd = ""; if (textBox2.Text.EndsWith(".com") || textBox2.Text.EndsWith(".com.br")) // tag é de um site { tagCmd = "site#"; // adiciona a tag } else if (textBox2.Text.EndsWith(".") || textBox2.Text.EndsWith("?") || textBox2.Text.EndsWith("!")) // é uma conversa { tagCmd = "chat#"; } else // é um arquivo do usuário ou um programa { tagCmd = "run#"; } string cmd = textBox1.Text + "#" + textBox2.Text; // cria uma tag de comando File.AppendAllText("comandos.txt", tagCmd + textBox1.Text + "#" + textBox2.Text + "$", Encoding.UTF8); // vamos escrever a tag do comando Speaker.Speak("comando adicionado!"); // diz algo textBox1.Text = ""; textBox2.Text = ""; } }
private void Loading_Load(object sender, EventArgs e) { label1.ForeColor = Color.FromArgb(this.BackColor.R, this.BackColor.G, this.BackColor.B); this.timer1.Start(); player.controls.play(); Speaker.Speak("INITIALISING ...."); Speaker.Speak("activating biometric and face recognition process"); Speaker.Speak("activating sissies "); Speaker.Speak("currently loading system files from your drives"); Speaker.Speak("currently getting all necessary files From Your drives"); Speaker.Speak(" checking current internet status "); Speaker.Speak("access granted"); Speaker.Speak(" Your Pc is now true connected"); Speaker.Speak("getting current Windows versions"); Speaker.Speak(" access granted"); Speaker.Speak("your Windows version is Microsoft Windows "); Speaker.Speak("loading graphical interface"); Speaker.Speak("graphical interface process is 78%"); Speaker.Speak("graphical interface process is 92%"); Speaker.Speak("graphical interface process is completed"); Speaker.Speak("getting access to Window"); Speaker.Speak("Windows traditional management"); Speaker.Speak("loading successfully"); Speaker.Speak("you and I connect to the Windows PC"); //Speaker.Speak("and your username Is Lasith Tharindu"); }
// Introdução ao assistente public static void Introduction() { Speaker.Speak("jarvis é o assistente do homem de ferro... como uma inteligência artiificial... "); Speaker.Speak(" ele é muito útil para o seu dono e criador... agora imagine se alguém, assim como você, tivesse o jarvis... "); Speaker.Speak(" ou outro assistente de outro nome... as possibilidades são muitas... felizmente.. muitos caras... ao redor do mundo "); Speaker.Speak(" Estados Unidos... India... Brasil... já tentaram criar um jarvis.. mas poucos tiveram oportunidade de obter... e ainda com muitos poucos "); Speaker.Speak(" comandos, e recursos... junte-se à nós e vamos criar um assistente virtual para a plataforma Windows... para que todos possam... aprender o que é "); Speaker.Speak(" inteligência artificial.. e de como a tecnologia pode mudar o mundo... eu sou jarvis e esse é o meu recado para você..."); }
private void SelectVoice_Load(object sender, EventArgs e) // form carregado { voices = GetVoices.GetVoicesFromCulture("pt-BR"); // instanciar o array de vozes Speaker.Speak("certo.. altere a voz do sintetizador"); foreach (var voice in voices) // percorrer vozes { comboBox1.Items.Add(voice); // adicionar voz } comboBox1.SelectedIndex = 0; // mostrar a primeria voz na comboBox }
public void SayFileThatIsPlaying() { string file = axWindowsMediaPlayer1.currentMedia.sourceURL; if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying) { string[] vet = file.Split('\\'); Speaker.Speak(vet[vet.Length - 1]); } }
public void OpenDirectory() // selecionar diretório { Speaker.Speak("certo, selecione um diretório para obter arquivos"); FolderBrowserDialog fd = new FolderBrowserDialog(); if (fd.ShowDialog() == DialogResult.OK) { PlayDirectory(fd.SelectedPath); // chamar método } }
public void OpenFile() { Speaker.Speak("selecione um arquivo de texto, para abrir"); OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { StreamReader sr = new StreamReader(ofd.FileName, Encoding.Default); richTextBox1.Text = sr.ReadToEnd(); } }
private void NormalWindow() { if (this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; Speaker.Speak("Normalizando a janela", "Como quiser!", "Tudo bem", "OK"); } else { Speaker.Speak("Já está em tamanho normal", "A janela já está em tamanho normal", "Já fiz isso"); } }
private void MinimizeWindow() { if (this.WindowState == FormWindowState.Normal || this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Minimized; Speaker.Speak("Minimizando a Janela!", "Como quiser!", "Tudo bem", "OK"); } else { Speaker.Speak("Já está minimizada", "A janela já está minimizada", "Já fiz isso"); } }
public void FullScreen() { try { axWindowsMediaPlayer1.fullScreen = true; Speaker.Speak("media player em tela cheia"); } catch (Exception ex) { Speaker.Speak(ex.Message); } }
public static void OSArch() { bool b = Environment.Is64BitOperatingSystem; if (b == true) { Speaker.Speak("o sistema é de 64 bits"); } else { Speaker.Speak("o sistema é de 32 bits"); } }
private void button1_Click(object sender, EventArgs e) { // vamos tratar possíveis erros try { Speaker.SetVoice(voices[comboBox1.SelectedIndex]); // setamos a voz selecionada na comboBox Speaker.Speak("feito, voz já foi alterada"); } catch (Exception ex) { Speaker.Speak("erro " + ex.Message); } }
public void ShowProcesses() { listBox1.Items.Clear(); // limpar Speaker.Speak("mostrando os processos em execução"); procs = Process.GetProcesses(); foreach (var proc in procs) { if (proc.MainWindowTitle != "") { long mem = proc.PagedMemorySize64 / 1024; listBox1.Items.Add(proc.MainWindowTitle + " " + mem.ToString() + " KB"); } } }
// Reproduizr lista de arquivos public void PlayListFiles(List <string> files) { var playList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("Lista de arquivos"); foreach (var file in files) // percorrer arquivos { playList.appendItem(axWindowsMediaPlayer1.newMedia(file)); // adicionar arquivo na playlist } axWindowsMediaPlayer1.Ctlcontrols.play(); // iniciar lista de reprodução axWindowsMediaPlayer1.currentPlaylist = playList; // setar a playlist axWindowsMediaPlayer1.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(state); // Método // das ações que ocorrem no media player Speaker.Speak("reproduzindo lista de arquivos"); }
public void PlayUrl(string url) { try { url = url.Replace("watch?v=", "v/"); axShockwaveFlash1.Movie = url; axShockwaveFlash1.Play(); Speaker.Speak("reproduzindo vídeo do youtube!"); } catch (Exception ex) { Speaker.Speak("ocorreu um erro! desculpe!"); } }
public void BackWindowToNormal() { try { if (this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; Speaker.Speak("tudo bem, voltando ao tamanho normal"); } } catch (Exception ex) { Speaker.Speak("erro " + ex.Message); } }
public void MinimizeWindow() // minimizar janela { try { if (this.WindowState == FormWindowState.Normal || this.WindowState == FormWindowState.Maximized) // se a janela estiver normal ou maximizada { this.WindowState = FormWindowState.Minimized; Speaker.Speak("minimizando a janela principal"); } } catch (Exception ex) { Speaker.Speak("erro " + ex.Message); } }
// quando clicar na pictureBox1 private void pictureBox1_Click(object sender, EventArgs e) { if (speechRecognitionActived == true) // se o reconhecimento de voz estiver ativo { sre.RecognizeAsyncCancel(); // para o reconhecimento speechRecognitionActived = false; // altera o valor da booleana Speaker.Speak("reconhecimento de voz desativado"); // diz algo } else if (speechRecognitionActived == false) { sre.RecognizeAsync(RecognizeMode.Multiple); speechRecognitionActived = true; Speaker.Speak("reconhecimento de voz ativado"); } }
public void CloseSelectedProcess() { try { Process[] p = Process.GetProcessesByName(procs[processIndex].MainWindowTitle); foreach (var a in p) { a.Kill(); } Speaker.SayWithStatus("fechando " + procs[processIndex].MainWindowTitle); } catch (Exception ex) { Speaker.Speak("erro " + ex.Message); } }
public void ChangeBackColor() { try { ColorDialog cd = new ColorDialog(); Speaker.Speak("selecione uma cor para o fundo"); if (cd.ShowDialog() == DialogResult.OK) { this.BackColor = cd.Color; } } catch (Exception ex) { Speaker.Speak("erro " + ex.Message); } }
public void ChangeSkin() // vamos usar async para evitar travamentos { try { OpenFileDialog ofd = new OpenFileDialog(); Speaker.Speak("selecione uma imagem para aplicar"); ofd.InitialDirectory = Directory.GetCurrentDirectory() + "\\Themes"; if (ofd.ShowDialog() == DialogResult.OK) { this.BackgroundImage = (Image)Image.FromFile(ofd.FileName); } } catch (Exception ex) { Speaker.Speak("erro " + ex.Message); } }
public static void SaySomethingFor(string phrase) // método que vai falar algo { switch (phrase) // switch, método mais rápido que if-else para muitas comparações { case "bom dia": DateTime time = DateTime.Now; // pega as horas if (time.Hour >= 5 && time.Hour < 12) // for de manhã { Speaker.Speak("olá senhor, desejo que você tenha um bom dia!"); break; } else if (time.Hour >= 12 && time.Hour < 18) // se for de tarde { Speaker.Speak("olá, boa tarde"); break; } else if (time.Hour >= 18 && time.Hour < 24) // se for e noite { Speaker.Speak("oi, boa noite, senhor"); break; } break; case "boa tarde": // boa tarde Speaker.Speak("boa tarde, senhor"); break; case "boa noite": Speaker.Speak("boa noite, tudo bem?"); break; case "ainda acordado jarvis?": Speaker.Speak("obrigado por perguntar senhor, mas eu não durmo.."); break; case "alguma ideia jarvis?": Speaker.Speak("não senhor"); break; case "obrigado jarvis": Speaker.Speak("por nada, senhor"); break; } }
private void ProcessList_Load(object sender, EventArgs e) { dictProcess = new Dictionary <string, int>(); listBox1.Items.Clear(); // limpar Speaker.Speak("mostrando os processos em execução"); procs = Process.GetProcesses(); int i = 0; foreach (var proc in procs) { if (proc.MainWindowTitle != "") { long mem = proc.PagedMemorySize64 / 1024; listBox1.Items.Add(proc.MainWindowTitle + " " + mem.ToString() + " KB"); dictProcess.Add(proc.ProcessName, i); i++; } } }
/// <summary> /// Faz algo sobre a lista de processos /// </summary> public static void ProcessesRunning() { try { Process[] procs = Process.GetProcesses(); // pega todos os processos Speaker.Speak("obtendo lista de processos"); foreach (Process proc in procs) // percorrer os processos { if (proc.MainWindowTitle != "") // se a janela tiver título { Speaker.Speak(proc.MainWindowTitle + " está usando " + Convert.ToString(proc.PagedMemorySize64 / 1024 / 1024) + " mega baites"); } } } catch (Exception ex) { Speaker.Speak("ocorreu um erro " + ex.Message); // fala o erro } }
public static string[] Seach(string search) { List <string> results = new List <string>(); try { using (WebClient wc = new WebClient()) { wc.Encoding = Encoding.UTF8; string youtube = "https://www.youtube.com/results?search_query="; if (search.Contains(" ")) { search = search.Replace(" ", "+"); } youtube += search; string html = wc.DownloadString(youtube); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); foreach (HtmlNode node in doc.DocumentNode.SelectNodes("\\a[@href]")) { if (node.InnerText.StartsWith("https://www.youtube.com/watch?v=")) { results.Add(node.InnerText); } string t = ""; results.ForEach(r => t += r + "\n"); MessageBox.Show(t); } } } catch (Exception ex) { Speaker.Speak("erro:" + ex.Message); } return(results.ToArray()); }
private static void CloseProcess(string cmd, string proc) { try // vamos usar try/catch { Process[] p = Process.GetProcessesByName(cmd); if (p[0] != null) // se o processo não for nulo { Speaker.SayWithStatus("fechando o " + proc); p[0].Kill(); } else // se for nulo { Speaker.Speak("desculpe, mas o " + proc + " não estar aberto"); } } catch (Exception ex) // jarvis vai nos ajudar no debug { Speaker.Speak("senhor, ocorreu um erro, desculpe, o erro foi, " + ex.Message); } }