About
The speech programmer is a web tool aimed at writing code based on voice commands. As of now, the tool only writes C code, and its usage is dependent upon various conditions that must be met when giving voice commands. Read this documentation to understand the proper usage of this tool for the best results.
Usage
Libraries
- To include a library, start the command with the word include.
- Follow the include word by the name of the library to be included.
- Do not use the .h in your command; this is included automatically when the include statement is written.
- Do not use the word hash or similar in your command. This is also added automatically.
- Include statements are always added at the top of the file.
Data Types
To use data types throughout the tool, use the following conventions:
- To use the int data type, use the word integer.
- To use the char data type, use the word character.
- To use the double or float data types, use the corresponding word itself.
Functions
- To define a new function, start the command with the word function.
- The word function must be immediately succeeded by the return type of the function.
- Follow the return type with the name of the function. The name of a function can be as long as required, and will automatically be converted to camel case.
- To pass parameters to the function, use the word takes after the name of the function. This word must then be succeeded by the return type of each parameter and the parameter name.
Example:
Voice command: function integer calculate average takes integer 'size'
Function Written: int calculateAverage(int size) {}
Variables
- To declare a variable, start the voice command with the data type of the variable. (Remember to use the above given conventions for data types)
- Follow the data type with the name of the variable. The name of the variable can be as long as required, and will automatically be converted to camel case.
- However, you may only declare one variable per line.
- To initialize a variable while declaring it, follow the name of the variable with the word equals, then give it the initial value.
- Characters will automatically be initialized within single quotes.
Example-1:
Voice command: integer size equals 5
Statement Written: int size = 5;
Example-2
Voice command: character test equals p
Statement Written: char test = 'p';
Printf
- To use the printf function, start the command with the word print.
- Follow the word with the quote to print.
- To use a variable in the quote, use the word percent/percentage in the quote. No need to use the identifier, such as 'd'; identifiers will be added automatically based on the variable's data type.
- To specify the variable to be used instead of the placeholder, use the word variable.
- Following the word variable, say the name of the variable to be used.
- To add a newline(\n)in the print quote, use the word line.
Example:
Voice command: print the value of test is percent line variable test
Statement written: printf("the value of test is %d\n ", test);
Scanf
- To use the scanf function, start the command with the word scan.
- Follow the word with the names of variables to be scanned. Format identifiers or a quote for scanf is not required. The quote will be written automatically based on the data types of variables.
- The word ampersand/and is not required before each variable either. The '&' symbol is added automatically before each variable.
Example:
Voice command: scanf test, size
Statement Written: scanf("%f%d", &test, &size);
If-Else
- To use the if-else construct, start the command with the word if or else.
- Follow the word with the condition. Preceed variable names with the word variable, and say constants (integers or chars) directly
- To add relational operators, use the words equals, greater, greater equals, less or less equals.
Example:
Voice command: if variable test greater equals 5
Statement Written: if (test >= 5) {}
If-Else
- To use the while loop construct, start the command with the word while.
- Follow the word with the condition. Preceed variable names with the word variable, and say constants (integers or chars) directly
- To add relational operators, use the words equals, greater, greater equals, less or less equals.
Example:
Voice command: while variable test greater equals 5
Statement Written: while (test >= 5) {}