Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Speech.Recognition;
- using System.Speech.Synthesis;
- using System.Threading;
- using System.Xml.Linq;
- using System.Xml;
- using System.IO;
- using GTA;
- namespace Speech_Recognizer
- {
- public class Form1 : Script
- {
- private SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
- private SpeechSynthesizer JARVIS = new SpeechSynthesizer();
- private string currentFunction;
- public Form1()
- {
- Tick += FunctionCaller;
- Game.Console.Print("Working!");
- recognizer.SetInputToDefaultAudioDevice();
- recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(File.ReadAllLines(@"C:\Program Files\Alex SR program\Alex.txt")))));
- recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(RecognizerSpeechRecognized);
- recognizer.RecognizeAsync(RecognizeMode.Multiple);
- }
- private void FunctionCaller(object sender, EventArgs e)
- {
- switch (currentFunction)
- {
- case "Reload":
- //insert code to reload
- currentFunction = null;
- break;
- case "Helicopter":
- Vector3 hPos = Player.Character.Position.Around(10.0f);
- World.CreateVehicle(new Model("ANNIHILATOR"), hPos);
- currentFunction = null;
- break;
- case "Sports Car":
- Vector3 scpos = Player.Character.Position.Around(10.0f);
- World.CreateVehicle(new Model("COMET"), scpos);
- currentFunction = null;
- break;
- case "Bike":
- Vector3 zpos = Player.Character.Position.Around(10.0f);
- World.CreateVehicle(new Model("NRG900"), zpos);
- currentFunction = null;
- break;
- case "Dont Leave Me Alone":
- case "Increase wanted level":
- Player.WantedLevel++;
- currentFunction = null;
- break;
- case "Leave Me Alone":
- case "Decrease wanted level":
- Player.WantedLevel--;
- currentFunction = null;
- break;
- }
- }
- private void RecognizerSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
- {
- currentFunction = e.Result.Text;
- switch (currentFunction)
- {
- //Commands
- case "Reload":
- JARVIS.Speak("Checking Ammo. Reloading Gun");
- break;
- case "Helicopter":
- JARVIS.Speak("Okay Sir");
- break;
- case "Sports Car":
- JARVIS.Speak("You May Drive Fast Sir.");
- break;
- case "Jarvis":
- JARVIS.Speak("May I Do Some Moding Sir?");
- break;
- case "Which game Is This":
- case "What game is this":
- case "Game Name Please":
- JARVIS.Speak("Sir Its Grand Theft Auto 4");
- break;
- case "A Car":
- JARVIS.Speak("Sports Car Or Normal Car?");
- break;
- case "Bike":
- JARVIS.Speak("As You Wish Sir");
- break;
- case "Dont Leave Me Alone":
- case "Increase wanted level":
- JARVIS.Speak("Giving You Company Sir");
- break;
- case "Leave Me Alone":
- case "Decrease wanted level":
- JARVIS.Speak("Bye Cops Dont Need You Anymore");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement