Introduction: Voice Control Any PC Game: GUIDE

About: Am a class 10 student going to appear for my board (17-18) exams very soon. 15yr old!

Certain games benefit from an element of voice control. I will be teaching you how to code the popular free game, Team Fortress 2, to respond to your voice. You won't be able to move and shoot guided by your voice alone, but certain actions in the game, for example calling for a medic or taunting lend themselves to voice control.

You will be using GlovePIE, a fantastic free program that uses its own coding language. Don't worry, this coding language is very simple and easy to pick up.

source- Alliance and this video

Step 1: Download and Install

Click here to download the file

extract it then install the app

Step 2: Coding!

it's a pretty simple part

Ok now you just need to code! I'll teach you how to code for Team Fortress 2, then you can apply the same technique to any other game.

1. IF statement The 'if' statement is arguably the most important. It means that IF the conditions specified are fulfilled, THEN it will carry out some actions. Don't worry if this doesn't make much sense to you right now, it will all become clear eventually. Look at the first picture; this is a typical IF statement. It means that IF it hears you say the word 'medic', it will THEN press 'E'.

2. 'said'In GlovePIE, 'said' just means what you say. It will compare your voice to the word 'medic', and if your voice matches the word 'medic', then the IF statement is fulfilled. In other words, this is how GlovePIE hears you. Here's another example:if said("hello", 5) then...This would fulfil the IF statement if you say the word 'hello'. The number (5) that comes after the word just means the level of confidence needed to fulfil the statement. 1 is the lowest, and 6 is the highest. If the number was 1, anything that sounds remotely like the word 'hello' would trigger the statement. Note that the word "hello" or "medic" needs to be in speech marks.

3. Press This just simulates a button press. In this case, the key for a Medic in TF2 is 'E', so it presses E, waits 10 milliseconds then releases E.

4. Keyboard.EThis just tells GlovePIE that you want to simulate a keyboard press. This works for most buttons on the keyboard, e.g. to press 'Alt' you would say: press keyboard.Alt. However, for the number keys (above the letters) you have to say: 'press key.1' or 'press key.5'.It works for the mouse too, to left click you could type: mouse.LeftButton

5. End ifThis tells GlovePIE that once it has pressed and released 'E', it has finished. If you have no 'end if', all the code underneath would be triggered whenever you say 'Medic'

Step 3: Continue Coding

Ok this is a tad more complex. In Team Fortress 2 (or TF2, for short), if you press 'X', then '2', your character shouts 'Spy!'. It is easy to make this voice controlled. Look at the code in the picture. It is exactly the same as the medic code, just with a few more lines for the '2' key. This presses x, releases x, presses 2, then releases 2. Actually quite simple.If you need to press two keys at the same time, just do something like this:If said("spy", 5) then press keyboard.x press keyboard,2 wait 10 ms release keyboard.x release keyboard.2 end if Ok now I want you to code an IF statement for calling for help in TF2. In game, you have to press 'C', then '1' to call for help. Code it so that if you say "help" the in game character shouts 'help'. Look at the next step to see if you got it right.

Step 4: RUN

if your code looks like this, then well done!!Don't forget to save your file. Here's one more finishing touch:Put this in to your code to make it so that when you say 'hide', the glovepie window disappears, and when you say 'show', the glovepie windows appears.if said("hide", 5) or said("hide glove pie", 5) then hidepie end if if said("show", 5) or said("show glove pie", 5) then showpie end if Notice the 'OR' statement - this means that GlovePIE will recognise both "hide" and "hide GlovePIE".

Now click on Run wrong thins will be highlighted

hope u enjoy it!

Step 5: Connect to Microphone!

you will communicating to the computer via a microphone,so remember to connect your PC to the microphone

Step 6: ENJOY!

Thanks for spending your precious time over my Instructable

you are all set to all you have to do is just open the game you codded and play it

if you want me to write code of any game or need help comment below i will reply as fast as i can.

THANK YOU AGAIN!