Voice Command Software for Video Games!

by TG_Ekik in Circuits > Computers

1139 Views, 9 Favorites, 0 Comments

Voice Command Software for Video Games!

Title Image.png

Hello! And welcome to my instructable, in which I will be teaching you very basic coding so you will be able to make your very voice command software that will work on virtually any game!

I will be teaching you how to create your own voice command software by breaking down the software commands in each step and explaining how exactly you can implement them, Please keep in mind that this tutorial is not meant to teach you the entirety of the coding language I will be using, but rather to supply a number of simple commands so that any beginner could create their own voice command software.

Although this method of coding can be applied to almost any game, I will be using Minecraft in this tutorial as it is an incredibly popular and relevant game.

Important Downloads

Glove Website.PNG

There are a few things to download;

The first thing that is necessary to download is a software called GlovePIE. This is the program we will be using to create our voice command program. You can either download from the download page of the website, or directly from the media fire page provided. If you want download from the download page it is necessary to download version 0.41 from the mediafire link(as pictured above) as all other download links are down.

Download Page - https://sites.google.com/site/carlkenner/asdfghjkl

MediaFire Page - http://www.mediafire.com/download/m32g1jxnnz1/Glov...

The second thing you can download is the small voice command program I made for the sake of this tutorial, which will be linked as a Mediafire download. It should be noted that this is an optional download.

Voice Command Program - http://www.mediafire.com/download/6crks104byr7exi/...

The Building Blocks

The Squiggly boops.PNG

The purpose of this steps is, essentially, to put explain the basic building blocks that we will be putting together to build a voice command program. The only drawback to using GlovePIE is that your commands are limited to button presses and typed out commands.

//Organization

The first building block is the ability to organize your coding. This done by creating lines of texts that won't be read by GlovePIE as coding. This is done by typing two slashes and then your line of text, for example:

//This is a comment

This will allow you to separate your commands into their types. (such as changing the time of day, and changing the game difficulty).

If said

The first thing that is necessary to code is the if said statement. This will allow GlovePIE to listen for a statement of your specification that will activate your command. It is necessary to write this statement in a specific format as follows;

If said("this is my command", 5) then

You must put the command within quotation marks, which must then be put within parenthesis. The number 5 placed after the comma is there to indicate how much your statement must sound as it is indicated. For example, if the number was placed there instead, anything sounding remotely close to "this is my command" would be read as accurate, whereas if it were 6 the only any statement that was 100% accurate would be read as accurate. It is also possible to make more than one statement activate your command, for example;

If said("this is my statement, 5) or said("actually this is", 5) or said("this too", 5) then

Lastly, it is necessary to type then at the end to signify that it is the end of that coding line.

Say

In order to have GlovePIE respond to you, it is necessary to write a say statement. By doing so, GlovePIE will say(through the speakers or headphones you are wearing). For example;

Say("hello there")

Typing this line of text will cause GlovePIE to state "hello there" upon activation of that line of code. This will come in handy in the future as it will act as a form of confirmation that your voice command went through.

Press/Release keyboard

In order for your command to actually be completed, GlovePIE needs to use your keyboard. As I mentioned earlier, this is the only shortcoming as voice commands are limited to what can be accomplished on a keyboard. However, this is useful as it is more convenient and sometimes quicker at typing than humans. Although I'll show how to create a full out command later, for now I will show you how to have GlovePIE press buttons. For example, if I wanted GlovePIE to press E, than I would type

Press keyboard.E

Wait 15 ms

Release keyboard. E

Firstly, don't worry about 'wait 15 ms', I'll explain that next. Secondly, in order to have GlovePIE press any button I have to type as I did above. Except for numbers, if you want GlovePIE to type any other button than you just need to replace said button name where E is. For example, if I wanted GlovePIE to press enter than I would type

Press keyboard.Enter

Wait 15 ms

Release keyboard.Enter

The release function is necessary to tell GlovePIE to stop pressing a button. Because of this, I can tell GlovePIE to press multiple buttons at once, for example.

Press keyboard.shift

Wait 15 ms

Press keyboard.E

Wait 15 ms

Release keyboard.E

Wait 15 ms

Release keyboard.Shift

Also, in order to have GlovePIE press a number, k need to type key.1 rather than keyboard.1, for example

Press key.1

Wait 15 ms

Release key.1

And with this you will be able to have GlovePIE type/press anything!

Wait

The wait function in GlovePIE causes the program to wait between each step of a command, for example

If said("hello", 5) then

Say("hello there")

Wait 1.5 S

Press keyboard.E

Wait 15 ms

Release keyboard. E

The wait function causes GlovePIE to wait 1 and a half seconds between saying 'hello there' and pressing E, and then causes it to wait 15 milliseconds between pressing and releasing E. This is necessary to give GlovePIE enough time to speak, and then enough time to type. If there is not at least 15 milliseconds between pressing and releasing buttons, then the button presses will be mixed up. If there is not at least 1 second for GlovePIE to talk(varying depending on the length of its statement) then it will be cut off. Note, 's' stands for seconds and 'ms' stands for milliseconds.

End if

The last building block for GlovePIE is the End if statement, which is necessary to put at the end if a command. This simply tells GlovePIE where to stop the steps of a command. Although there will be no example on this page, there will be on the next as it will be better shown there.

Now you are ready to put all of your building blocks together! On the next page, I will show you a simple command to put in Minecraft, and the you will be able to write your own voice commands!

Putting It All Together!

Now here is a simple voice command where GlovePIE will type out hello for you in Minecraft!(assuming that your button for opening the chat is C) Once you are done coding your program, press the little green arrow button at the top of the window to run it!

If said ("say hello", 5) then

Say("saying hello")

Wait 1.5 S

Press keyboard.C

Wait 15 ms

Release keyboard.C

Wait 15 ms

Press keyboard.H

Wait 15 ms

Release keyboard.H

Wait 15 ms

Press keyboard. E

Wait 15 ms

Release keyboard.E

Wait 15 ms

Press keyboard.L

Wait 15 ms

Release keyboard.L

Wait 15 ms

Press keyboard.L

Wait 15 ms

Release keyboard.L

Wait 15 ms

Press keyboard.O

Wait 15 ms

Release keyboard.O

Wait 15 ms

press keyboard.Enter

Wait 15 ms

Release keyboard.Enter

Wait 15 ms

End if


I hope you enjoyed my instructable! And I hope you make amazing voice command software!