-
1Step 1
Finding the Right Speech Recognition System
The very first thing that I required was a speech recognition system that would allow me implement my own commands and train my voice on the same commands. In other words I wanted the functionality where the system would accept my own customized voice commands and upon recognizing the commands the system would then run an executable or a program that I have implemented. While I was looking for such system on the internet, I stumbled upon a PC based speech recognition system called "TAZTI". I selected this software as the speech recognition front end is because it satisfied the main two requirements: firstly it allows the user to create their own custom voice commands and secondly the system allows user to run their own program or executable upon recognizing these commands. There are quite a few other useful features in the Tazti speech recognition software (can be obtained from their website www.tazti.com ) Older versions of the software were freeware but the current versions are paid however they do provide a trial version for 15 days.
-
2Step 2
Interfacing with the PC
he second thing that I needed was a way to interface an electrical appliance with the PC using possibly the parallel or the serial or the USB port . So when a voice command is recognized in the PC a program would be executed which then sent a control command to the interfacing circuit to activate or de-activate a relay that controlled the electrical appliance or the gadget. I chose to use an off-the-shelf PIC micro-controller board that also had a relay and a serial port interface on the same board. You could use any such micro-controller board for an example Arduino.While looking for such micro-controller board I came across PIC-MT a development board for 28 pin PIC microcontroller from Olimex (can be obtained from their website www.olimex.com ). This board comes with a Serial/RS232 interface which can directly be connected to a PC serial port and an on-board circuit with a relay. All the details about the board such as schematic/circuit diagram and user manual etc are available from their website. I used PIC 16F876A for my prototype and implemented the firmware for the micro-controller in 'C'. I have also used the PIC boot loader and downloader software from Sparkfun (from www.sparkfun.com ). The boot loader allowed me to download the firmware in hex in to the program memory of the micro-controller over the serial port of the PC without requiring a proper PIC programmer and the special board socket for PIC programmers. Also this was carried out while keeping the micro-controller in the chip socket on the board, i.e. ICSP (In Circuit Serial Programming). Although I did have to program the boot loader for the very first time using the PIC programmer (PIC Start Plus or similar) into the micro-controller.
-
3Step 3
PC Serial Driver/Client Program
I implemented a simple 'C' program (essentially a Serial/RS232 driver and a client program) for the PC which would send a control command over to the serial port to the PIC board whenever this program is executed. The PIC serial server program would then listen to the commands arriving on the serial port and upon recognizing a control command it would perform a task(s) such as turning ON the relay or turning OFF the relay.
-
4Step 4
PC Serial Driver/Client Code
The 'C' Serial/RS232 driver/client program sends command word 27 to the PIC board. I programed the voice command to be "TV ON". This code has been successfully tested on Windows XP. For the voice command "TV OFF" the command word was 28. This 'C' program is in older style, shown here as an example, more modern Win32 user mode driver program could easily be written using Windows API for accessing serial port.
/*---------------------------------------------------------------------------------------------------*/
#include <dos.h>
#include <stdio.h>
#include <conio.h>/* Serial Ports Address, using COM2 */
#define PORT2 0x2F8
void main(void)
{
char command;
/* Turn off interrupts on Port2 */outportb(PORT2 + 1 , 0);
/* Setting DLAB ON */
outportb(PORT2 + 3 , 0x80);
/* Setting Baud rate to 9600 - Divisor Latch Low Byte */
outportb(PORT2 + 0 , 0x0C);
/* Set Baud rate - Divisor Latch High Byte */
outportb(PORT2 + 1 , 0x00);
/* 8 Bits, No Parity, 1 Stop Bit */
outportb(PORT2 + 3 , 0x03);
/* FIFO Control Register */
outportb(PORT2 + 2 , 0xC7);
/* Turn on DTR, RTS, and OUT2 */
outportb(PORT2 + 4 , 0x0B);
command = 27;
/* Sending the command to the Serial Port */
outportb(PORT2, command);
} -
5Step 5
PIC Firmware (Serial Port Server Program)
The firmware is essentially a server program running on the board, which listens to commands arriving via the serial port from the PC and executes the commands i.e. Toggle a port pin and drive a relay. You could make the controller carry out anything you like.
I would like to show the part of the PIC-16F876A firmware that receives the command from the PC over the serial port and toggles a pin which then turns the relay ON or OFF. The following code has been extracted from a larger working firmware program so it has not been tested in its isolated form.
/*----------------------------------------------------------------------------*/
//#define HS_Osc //The board has the High Speed = 20MHz Crystal Oscillator
//#include "16F876a.h" // device dependent interrupt definitions
//#pragma config|= 0x3F32 //HS Ocs
//the following line is to not overwrite the PIC boot loader part in the program memory#pragma origin 4
#define RELAY PORTA.1
#define OFF 0
#define ON 1
//RX routine for receiving data over the Serial Port
unsigned char ReadByte(void) {
// wait to receive character
while(!RCIF);
// return received character
return RCREG;
}
void main(void) {
unsigned char command;
INTCON = 0x0;// Disable ineruptCMCON = 0x07;// Comparators Off
ADCON1 = 0x06;// Port as Digital IO
TRISA = 0b.0000.0000;//0 = Output, 1 = Input
TRISB = 0b.1110.1111;// All as input, except LED pin
TRISC = 0b.1000.0000;//RC7 is RX which is input and RC6 is TX which is output
// RX Setting, 8bit, enable receive,
RCSTA = 0x90;
// TX Setting, 8bit, Asynchronous mode, High speed
TXSTA = 0x24;
// Set Baudrade - 9600 (from datasheet baudrade table)
SPBRG = 129;
while(1) {
command = ReadByte();//receive a character
if(command == 27) { //if the character is TV ON, 0x27
RELAY = ON; //Turning ON the pin that is connected to the relay
}
else if (command == 28) {
RELAY = OFF;
}
}
} -
6Step 6
Making Your Own PIC Board
Since the PIC-MT board has many other features, If you would like to make your own PIC micro-controller board to carry out just the above functionality all you require is following, you will need a PIC programmer to program your PIC:
1) PIC16F876A
2) A crystal oscillator: 20MHz
3) 2 Capacitors: 22pF
4) 1 Transistor to drive the relay
5) 1 Relay
6) 5V supply to the PIC controller.
This can be achieved using a dedicated power supply such as wall adapter or make your own using the 7805 regulator Integrated Circuit.
7) A way to interface with the PC serial port. There are several ways to achieve this, for more details on how to implement the following please use your favorite search engine:
(7.1) MAX232 Serial Driver/Receiver Integrated Circuit
(7.2) FTDI- FT232R USB to UART Integrated Circuit
(7.3) A USB dongle that converts USB to Serial and provides you with an emulated Serial port.
(7.4) A two transistor level converter circuit for directly interfacing with the PC serial port.
Similarly you may choose to use an ARDUINO board instead.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
thanks v much.
Are you sure? yes | no
Are you sure? yes | no