public GideonBase() { InitializeComponent(); // var image = new BitmapImage(); // ImageBehavior.SetAnimatedSource(BgImage, (ImageSource) new ImageSourceConverter().ConvertFromString(GideonPath.Background)); GrammarTableObj = new Hashtable(); RemainderObj = new RemainderUI(); RemainderUI.ReadFromFile(); GalleryObj = new GalleryUI(); aobj = new Alaram(); try { EngineObj = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-IN")); EngineObj.SetInputToDefaultAudioDevice(); SynObj = new SpeechSynthesizer { Volume = 100 }; SynObj.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Teen, 18, System.Globalization.CultureInfo.CurrentUICulture); LoadGrammar(Modules.Gideon, Grammars.GideonGrammar); LoadGrammar(Modules.PcInfo, Grammars.PcInfoGrammar); EngineObj.RecognizeAsync(RecognizeMode.Multiple); EngineObj.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(Engine_SpeechRecognized); MHObj = new ModulesHandler(); MHObj.OpenModule(Modules.Remainder); dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(alaramTimer); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); Timer = new DispatcherTimer(); Timer.Tick += new EventHandler(showTime); Timer.Interval = new TimeSpan(0, 0, 1); Timer.Start(); date.Content = DateTime.Now.Date.ToShortDateString(); DateTimeGrid.ToolTip = DateTime.Now.ToString("F"); setBackgrounds(); WeatherUpdate(); NewsUpdate(); SetValues(); quotes = Motivational_Quotes.FetchQuotes(); Greet(); } catch (System.Net.WebException) { } catch (Exception e) { MessageBox.Show(e.ToString()); } }
//private static Grammar GenerateGrammar() //{ // string[] spaction1 = {"What"}; // string[] spaction2 = {"is"}; // string[] action1 = { "good", "today's","the","your","Who","Media"}; // string[] action2 = { "morning", "evening", "night","date","time","name","created you","Player" }; // GrammarBuilder action1_action2 = new GrammarBuilder(new Choices(action1)); // action1_action2.Append(new Choices(action2)); // GrammarBuilder spaction1_spaction2_action1_action2 = new GrammarBuilder(new Choices(spaction1)); // spaction1_spaction2_action1_action2.Append(new Choices(spaction2)); // spaction1_spaction2_action1_action2.Append(new Choices(action1)); // spaction1_spaction2_action1_action2.Append(new Choices(action2)); // Grammar GrammarGenerated = new Grammar(new Choices(action1_action2, spaction1_spaction2_action1_action2)); // return GrammarGenerated; //} public void Engine_SpeechRecognized(object Object, SpeechRecognizedEventArgs e) { switch (e.Result.Text) { /// <summary> /// Media Player /// </summary> /// <returns></returns> case "open music": case "open mediaplayer": LoadGrammar(Modules.MediaPlayer, Grammars.MediaPlayerGrammar); MHObj.OpenModule(Modules.MediaPlayer); break; case "close music": case "close mediaplayer": MHObj.CloseModule(Modules.MediaPlayer); UnLoadGrammar(Modules.MediaPlayer); songTB.Text = ""; break; case "play": case "play video": case "play audio": case "next": case "previous": case "stop": case "pause": case "up": case "increase volume": case "down": case "decrease volume": case "mute": case "full volume": case "maximize": case "minimize": Song songname = new Song(); MHObj.MediaPlayerHandler(e.Result.Text, songname); mediaplayergrid.DataContext = songname; break; ///////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// weather forecast /// </summary> /// <returns></returns> /// case "open WeatherForecast": case "open WeatherInformation": // LoadGrammar(Modules.WeatherForecast, Grammars.WeatherForecastGrammar); MHObj.OpenModule(Modules.WeatherForecast); break; case "close WeatherForecast": case "close WeatherInformation": MHObj.CloseModule(Modules.WeatherForecast); // UnLoadGrammar(Modules.WeatherForecast); break; //case"pune": //case "new york": //case "chinchwad": //case "sangli": //case "brazil": //case "mexico": // MHObj.WeatherForecastHandler(e.Result.Text); // break; ////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// news /// </summary> /// <returns></returns> /// case "open News": LoadGrammar(Modules.News, Grammars.NewsGrammar); MHObj.OpenModule(Modules.News); break; case "close News": MHObj.CloseModule(Modules.News); UnLoadGrammar(Modules.News); break; case "Business News": case "Entertainment News": case "General News": case "Health News": case "Science News": case "Sports News": case "Technology News": MHObj.NewsHandler(e.Result.Text); break; ////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Alarm & Remainder /// </summary> /// <returns></returns> /// case "set alarm": remainder_grid.Visibility = Visibility.Hidden; alaram_grid.Visibility = Visibility.Visible; break; case "set remainder": remainder_grid.Visibility = Visibility.Visible; alaram_grid.Visibility = Visibility.Hidden; break; ////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// PC information /// </summary> /// <returns></returns> /// case "ram": case "mac address": case "machine name": case "username": case "check internet connection": case "tell me your processor information": case "good morning": case "good night": case "good evening": case "what is the time": case "hello": case "todays date": case "battery status": case "who are you": case "how are you": PcInfo.PcInformation p = new Gideon.PcInfo.PcInformation(); PcInfo.Information i = new PcInfo.Information(); p.Handler(e.Result.Text, i); PcInfoGrid.DataContext = i; break; ////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Gallery /// </summary> /// <returns></returns> /// case "My Gallery": MHObj.OpenModule(Modules.Gallery); break; case "close My Gallery": MHObj.CloseModule(Modules.Gallery); break; case "Show Command List": ShowCmdList(true); break; case "Hide Command List": ShowCmdList(false); break; case "open game": Process.Start(@"C:\Users\Harshal\Desktop\Minesweeper\Minesweeper\bin\Debug\Minesweeper.exe"); break; case "take screenshot": //SynObj.SpeakAsync("Taking the screenshot"); //try //{ // System.Windows.Forms.SendKeys.Send("{PRTSC}"); // System.Drawing.Image img = System.Windows.Forms.Clipboard.GetImage(); // string path = @"C:\Users\Harshal\Desktop\My_Personal_Assistent\screenshots\" + "Temp" + DateTime.Now.Millisecond + ".jpg"; // img.Save(path); //} //catch (Exception e1) //{ // System.Windows.Forms.MessageBox.Show(e1.ToString()); //} break; } }