Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Video URL: https://www.youtube.com/watch?v=rgZ-BD4Gzc4
- Hier ist der neue Deklarationsteil:
- #region Deklaration der Engine und variablen
- SpeechRecognitionEngine h = new SpeechRecognitionEngine();
- SpeechSynthesizer s = new SpeechSynthesizer();
- CoreAudioDevice defaultPlaybackDevice = new CoreAudioController().DefaultPlaybackDevice;
- //Boolean für den Ruhemodus
- public Boolean hören = true;
- //Boolean für die Google suche
- public Boolean suche = false;
- //Boolean für die Wikipedia suche
- public Boolean wasist = false;
- //Verzeichnis URI
- public string vuri = "C:\\Users\\Freddy\\Visual Studio";
- #endregion
- Hier finden ihr den Code für die neue suche:
- #region wikipedia suche core
- if (wasist)
- {
- try
- {
- s.SpeakAsync(
- "Das Internet sagt dazu folgendes:");
- lbl_ans.Text = "Das Internet sagt dazu folgendes";
- WebClient client = new WebClient();
- using (Stream stream =
- client.OpenRead(
- "http://de.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&explaintext=1&titles=" + modus)
- )
- using (StreamReader reader = new StreamReader(stream))
- {
- JsonSerializer ser = new JsonSerializer();
- Result result = ser.Deserialize<Result>(new JsonTextReader(reader));
- foreach (Page page in result.query.pages.Values)
- txt_info.Text = page.extract;
- string antwort = txt_info.Text;
- string small = antwort.Substring(0, 500);
- s.SpeakAsync(small);
- }
- wasist = false;
- }
- catch (Exception)
- {
- s.SpeakAsync("Nichts, es sagt nichts, komisch, sehr komisch, du musst da wohl was durcheinander gebracht haben. Ich sschüttel den Google automaten aber da kommt nur leeres klimpern! Versuch es noch einmal.");
- wasist = false;
- }
- }
- #endregion
- Hier findet ihr das neue case:
- if (hören == true && suche == false && wasist == false)
- {
- lbl_quest.Text = e.Result.Text;
- switch (e.Result.Text)
- {
- case "was ist":
- wasist = true;
- tab_control.SelectTab(tab_wiki);
- break;
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement