D3NCE

KÜNSTLICHE INTELLIGENZ IN C# SCHREIBEN – PART 13 – GOOGLE SU

Dec 21st, 2018
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. Video URL: https://www.youtube.com/watch?v=pD3HdzpX7cg
  2.  
  3. Hier die neue public partial Class:
  4.  
  5. #region Deklaration der Engine und variablen
  6. SpeechRecognitionEngine h = new SpeechRecognitionEngine();
  7. SpeechSynthesizer s = new SpeechSynthesizer();
  8.  
  9. CoreAudioDevice defaultPlaybackDevice = new CoreAudioController().DefaultPlaybackDevice;
  10.  
  11. //Boolean für den Ruhemodus
  12. public Boolean hören = true;
  13.  
  14. //Boolean für die Google suche
  15. public Boolean suche = false;
  16.  
  17. //Boolean für die Wikipedia suche
  18. public Boolean wasist = false;
  19.  
  20. #endregion
  21.  
  22.  
  23.  
  24. Hier der neue SpeechRecognizer:
  25.  
  26. void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
  27. {
  28. //bedingungen für ruhemodus
  29.  
  30. string modus = e.Result.Text;
  31.  
  32. if (modus == "sprich")
  33. {
  34. hören = true;
  35. }
  36. if (modus == "still")
  37. {
  38. hören = false;
  39. }
  40.  
  41. #region google suche core
  42. if (suche)
  43. {
  44. Process.Start("https://www.google.de/search?hl=de&source=hp&ei=Q4-lWrq1BIWWsAep25jwDA&q=" + modus);
  45. suche = false;
  46. }
  47. #endregion
  48.  
  49.  
  50.  
  51. if (hören == true && suche == false && wasist == false)
  52. {
  53. lbl_quest.Text = e.Result.Text;
  54. switch (e.Result.Text)
  55. {
  56.  
  57. #region google suche
  58. case "suche nach":
  59. suche = true;
  60. break;
  61.  
  62. #endregion
  63. }}}
Add Comment
Please, Sign In to add comment