You have just completed entering a program containing almost 1,000 statements, yet during all that programming your fingers never touched a keyboard. Anticipating the best, you lean back in your chair and with a single spoken command you see what an evening’s worth of effort will bring. “RUN” you command . . . and RUN the program does.
Is this scenario a dream? Hardly. Take a look through any current technology related publication and you are likely to come across an article or advertisement concerning speech recognition. It is a technology which offers an alternative to the normal human-machine interface consisting of direct physical contact. Today you flip a switch, press a key, and turn a dial. Tomorrow you may only have to speak the command to perform these tasks.
But back to today, and in particular to the subject of this article: a simple speech recognition program for ZX/TS computers (with at least 16K RAM). The word “simple” should be emphasized. The program is relatively simple to enter and run. It is limited to recognizing only ten simple words (but ten words of your choice!). It is not designed to replace your keyboard (sorry), rather it is an experimental tool. With consistent pronounciation the program will recognize and display the correct word approximately 9 out of 10 times. Not bad . . . but I hope not to hear from someone who has interfaced the system to control the brake and accelerator in his automobile!
The speech recognition program has three major parts:
1) A speech input routine. This displays a “voice print” in the form of a histogram, and is actually a pseudo frequency spectrum of a vocalized word or sound.
2) A file system. Up to ten separate voice prints along with the corresponding word (string) are stored. These voice prints and strings are employed during speech recognition for comparison.
3) A speech recognition routine. This compares a newly spoken voice print to the prints stored in the file. A string corresponding to the best matching voice print entry is then displayed on the TV screen.

Each of these three parts consists of Basic statements with calls to appropriate machine code routines when fast and efficient program execution is required.
Hardware
To use the program, a small piece of hardware must be constructed. This provides an amplified voice signal to the computer’s ear input. Parts for the board can be readily obtained at most Radio Shack stores and G. Russell Electronics. Even for those with limited construction experience, assembly should take no more than a couple of hours.
Step by Step Construction
A complete parts list and required tools are given in Table 1.
Table 1. Amplifier part and tool list.
Qty Description Radio Shack
Part No.
1 Experimenter's Grid Board 276-158
1 Crystal Mike Element 270-088
1 8 Pin Low Profile Socket 276-1995
1 3 Conductor Mini Jack 274-249
1 TL 081 Single BiFET OP AMP 276-1716
or
1 TL 091 Single N-FET Op AMP 276-1745
1 DPDT Micro Miniature Toggle Switch 275-626
2 9 Volt Battery Snaps 270-325
2 9 Volt Battery 23-464
1 10 Meg Ohm resistor 1/4 watt .5% 271-1365
3 10 K Ohm resistor 1/4 watt .5% 271-1335
1 1 K Ohm resistor 1/4 watt .5% 271-1321
1 470 K resistor 1/4 watt .5% 271-1354
Miscellaneous
3 feet of 22 gauge (or smaller) single conductor wire Rosin core solder
Tools
1) 25-40 Watt Soldering Iron
2) Diagonal Wire Cutters
3) Needle Nose Pliers
4) Electric or Hand Drill
5) 7/32" Drill Bit
6) 1/16" Drill Bit

1) Lay out the board. Photo 1 shows our prototype. We found this configuration comfortable to hold in the palm of a hand. Component layout is given in Figure 1 (Note: the copper pad side of the grid board is down).
2) Drill a 7/32″ hole for the DPDT power switch at hole W-3 (W-3 are grid board coordinates). With the 1/16″ drill bit, enlarge the holes at positions C-13, D-13, V-13, and W-13 to allow the battery snap leads to pass. Also with the 1/16″ drill bit, enlarge the hole at J-30 and drill two new holes to accommodate the 3 conductor mini lack. Make sure the threaded portion of the jack extends past the board edge so that the cassette cable mini plug can be fully inserted.
3) Install the DPDT switch in the 7/32″ hole with the supplied hardware.
4) Install the 3 conductor mini jack into the proper holes. A small amount of silicon rubber sealer (or other available adhesive) will help to fix the jack onto the board. Solder the jack terminal at hole J-30 to its respective pad.
5) Solder a 1 1/2″ piece of the 22 gauge single conductor wire to each of the crystal mike element terminals. Bend these wires perpendicular to the element, and insert the (-) terminal lead in hole K-6 and (+) terminal lead in hole N-6. Solder these wires to their respective pads. Let the excess wire remain unconnected temporarily.
6) Insert the 8 pin IC socket into the board. The socket should occupy holes K-10 through K-13 and holes N-10 through N-13. Pin 1 is located at hole N-13; pin 8 is located at hole K-13. After insertion, bend the leads of the socket outward to hold it in place. Do not install the OP AMP at this time.
7) Insert resistor leads as in Table 2. After positioning a resistor, solder the protruding lead to its respective pad.
8) Bend the leads of the resistors to make the required connection(s). See Figure 2. Solder where necessary. As a check for completeness, trace over the schematic with high lighting pen after each connection has been made. Photo 2 shows the prototype backside.
9) Wire the connections to the mini jack. Connect IC socket pin 6 (hole K-11) to the jack terminal extending through hole J-30. This is the amplifier output. It must be connected to the jack terminal which makes contact with the tip of the cassette cable plug. Connect either of the other two jack terminals to ground.
10) Complete the circuit by wiring the battery and switch leads. Ground is established by tying and soldering together the black lead of the right side battery snap (hole V-13) with the red lead of the left side battery snap (hole D-13). Solder this junction to the resistor leads extending through holes T-11 and T-12. The ground lead of the crystal mike (hole K-6) is also connected to this point. With a piece of the 22 gauge wire, connect one of the mini jack ground terminals to the same ground junction.
11) Connect and solder the remaining red and black battery snap leads to the lower two switch terminals. Solder a 2″ wire to each of the two center terminals of the switch. Taking note of the proper wire, solder the wire which makes contact through the switch with the red battery lead to IC socket pin 7 (V+). Solder the other center switch terminal wire to IC socket pin 4 (V-).
12) Install the op amp. The recessed dot on top of the op amp indicates pin 1, and should be away from the crystal mike element (approximately lined up with hole N-13).
13) Finally, making sure the DPDT switch is off (lever down), clip on the two 9 volt batteries to the battery snaps.
This completes amplifier board assembly.
Table 2. Resistors and locations.
Resistor Board Location 10K Ohm (Brn Blk Org) J-9, N-9 10 K Ohm N-14, N-18 10 K Ohm O-14, O-18 10 Med Ohm (Brn Blk Blu) J-11, J-15 1 K Ohm (Brn Blk Red) O-12, T-12 470 K Ohm (Ye) Vio Yel) 0-11, T-11


Listing 1. Speech Recognition Program.
1 REM [machine code: 270 characters, entered with Listing 2 from Table 3; printed as unreadable symbols]
5 IF USR 16758<>64 THEN PRINT
AT 10,10;"BAD LOAD"
10 DIM C(1)
15 DIM T$(10,10)
20 CLS
25 PRINT AT 7,1
30 PRINT TAB 12;"MENU",,
35 PRINT TAB 6;"1. VOICEPRINT
DISPLAY"
40 PRINT TAB 6;"2. VOICEPRINT
FILE"
45 PRINT TAB 6;"3. RECOGNITION
"
50 PRINT TAB 6;"4. CLEAR FILES
"
55 PRINT TAB 6;"5. DISPLAY STR
ING FILE"
60 PRINT TAB 6;"6. STOP"
62 PRINT ,,,,,,TAB 8;"INPUT SE
LECTION"
65 FAST
70 INPUT S
75 IF S<=6 THEN GOTO S*200
80 GOTO 70
199 REM **VOICEPRINT DISPLAY***
200 RAND USR 16520
205 LET K=22528
210 CLS
215 POKE 16577,INT (K/256)
220 POKE 16576,K-256*INT (K/256
)
225 RAND USR 16575
230 PRINT AT 2,20;"AGAIN? (Y/N)
"
235 SLOW
240 IF INKEY$="" THEN GOTO 240
245 FAST
250 LET B$=INKEY$
255 IF B$="N" THEN GOTO 20
260 IF B$="Y" THEN GOTO 200
265 IF B$="5" AND K<=22719 THEN
LET K=K+1
270 IF B$="8" AND K>=22529 THEN
LET K=K-1
275 GOTO 210
399 REM *** VOICERRINT FILE ***
400 CLS
405 PRINT AT 10,1;"ENTER STRING
TO BE RECOGNIZED"
410 INPUT Z$
415 PRINT AT 12,1;"ENTER FILE P
OSITION"
420 INPUT R
425 LET T$(R)=Z$
430 PRINT AT 14,1;"PRESS ENTER
TO BEGIN"
435 INPUT F$
440 CLS
445 FOR I=0 TO 7
450 RAND USR 16520
455 POKE 25997,I
460 RAND USR 16615
465 PRINT AT 10,16;I+1
470 SLOW
475 PAUSE 30
480 FAST
485 NEXT I
490 POKE 25996,R
495 RAND USR 16641
500 PRINT AT 12,13;"AGAIN? (Y/N
)"
505 INPUT B$
510 IF B$="Y" THEN GOTO 400
515 IF B$="N" THEN GOTO 20
520 GOTO 505
599 REM *** RECOGNITION ***
600 RAND USR 16520
605 RAND USR 16707
610 CLS
615 PRINT AT 12,10;T$(PEEK 2599
9+1)
620 SLOW
625 PAUSE 60
630 FAST
635 IF INKEY$<>"" THEN GOTO 20
640 GOTO 600
799 REM *** CLEAR FILES ***
800 FOR I=1 TO 10
805 LET T$(I)=""
810 NEXT I
815 FOR I=26000 TO 26640
820 POKE I,0
825 NEXT I
830 GOTO 20
999 REM ** DISPLAY STRING FILE
1000 CLS
1005 FOR I=1 TO 10
1010 PRINT AT (5+I),10;I;". ";T$
(I)
1015 NEXT I
1020 PRINT ,,,," PRESS ANY KE
Y TO CONTINUE"
1025 SLOW
1030 IF INKEY$="" THEN GOTO 1030
1035 FAST
1040 GOTO 20
1200 STOP
Table 3. Machine code and addresses.
16520 33 16582 205 16645 168 16708 144
16521 0 16583 207 16646 97 16709 101
16522 88 16584 64 16647 205 16710 1
16523 6 16585 35 16648 38 16711 255
16524 255 16586 12 16649 65 16712 0
16525 54 16587 29 16650 123 16713 197
16526 0 16588 32 16651 2 16714 17
16527 5 16589 248 16652 3 16715 0
16528 35 16590 201 16653 62 16716 88
16529 194 16591 126 16654 104 16717 14
16530 141 16592 167 16655 185 16718 0
16531 64 16593 200 16656 32 16719 6
16532 6 16594 254 16657 245 16720 64
16533 255 16595 43 16658 58 16721 26
16534 33 16596 56 16659 140 16722 150
16535 0 16597 2 16660 101 16723 48
16536 88 16598 62 16661 1 16724 2
16537 14 16599 43 16662 64 16725 47
16538 254 16600 71 16663 0 16726 60
16539 237 16601 197 16664 33 16727 129
16540 120 16602 213 16665 80 16728 48
16541 242 16603 229 16666 101 16729 2
16542 155 16604 205 16667 9 16730 62
16543 64 16605 178 16668 61 16731 255
16544 44 16606 11 16669 32 16732 79
16545 237 16607 225 16670 252 16733 35
16546 120 16608 209 16671 17 16734 19
16547 250 16609 193 16672 40 16735 5
16548 160 16610 5 16673 100 16736 32
16549 64 16611 194 16674 235 16737 239
16550 52 16612 217 16675 237 16738 121
16551 5 16613 64 16676 176 16739 193
16552 200 16614 201 16677 201 16740 185
16553 237 16615 6 16678 197 16741 50
16554 120 16616 64 16679 62 16742 216
16555 250 16617 33 16680 8 16743 89
16556 169 16618 160 16681 1 16744 48
16557 64 16619 97 16682 0 16745 5
16558 46 16620 58 16683 0 16746 79
16559 0 16621 141 16684 17 16747 120
16560 17 16622 101 16685 0 16748 50
16561 220 16623 133 16686 0 16749 143
16562 255 16624 111 16687 78 16750 101
16563 27 16625 17 16688 235 16751 4
16564 122 16626 0 16689 9 16752 62
16565 179 16627 88 16690 235 16753 10
16566 200 16628 213 16691 61 16754 184
16567 237 16629 17 16692 35 16755 32
16568 120 16630 8 16693 32 16756 212
16569 242 16631 0 16694 248 16757 201
16570 179 16632 25 16695 6 16758 33
16571 64 16633 209 16696 3 16759 136
16572 195 16634 26 16697 151 16760 64
16573 160 16635 119 16698 203 16761 151
16574 64 16636 19 16699 26 16762 6
16575 33 16637 5 16700 203 16763 238
16576 0 16638 32 16701 27 16764 134
16577 88 16639 244 16702 5 16765 35
16578 14 16640 201 16703 32 16766 5
16579 0 16641 1 16704 248 16767 32
16580 30 16642 40 16705 193 16768 251
16581 64 16643 100 16706 201 16769 79
16644 33 16707 33 16770 201
Listing 2. Machine code loader.
5 FAST
10 LET K=16520
15 PRINT AT 10,10;K
20 INPUT I
25 POKE K,I
30 LET K=K+1
35 GOTO 15
Listing 3. Basic routine for MC dump.
50 LET K=16520
55 CLS
60 FOR I=0 TO 19
65 PRINT PEEK (I+K),PEEK (I+K+
20)
70 NEXT I
75 INPUT J
80 LET K=K+40
85 GOTO 55
Speech Recognition Program
Listing 1 provides the speech recognition Basic program. Line 1 is a REM statement which contains the machine code routines. Once entered, Line 1 must never be edited. Doing so may unintentionally alter the machine code routines. Enter the program as follows. Remember, SAVE frequently.
1) Type a REM statement containing 270 spaces. Although this statement does not have to be numbered Line 1, it must be the first statement in the program.
2) Enter Listing 2.
3) RUN this program. From Table 3 INPUT the appropriate decimal entry for the displayed address. For example, the entry for 16520 is 33, for 16566 is 200. After typing each entry, press ENTER. Continue until all entries have been made. To exit the program, input a non-numeric character (such as W). The program will abort, giving an error code.
4) Check your work by typing the following line (without a line number)
PRINT USR 16758
Press ENTER. If the result displayed is 64, skip step 5 and proceed with step 6.
5) If you did not get 64 in step 4, you must find the error in the machine code. Listing 3 gives a Basic routine which dumps forty sequential bytes of memory in decimal format, starting with the byte at address 16520. The data is displayed in two columns reading down without the addresses. The second column starts at an address which is 20 locations higher than the beginning of the first. The next 40 bytes can be examined by inputting any number and pressing ENTER. You must keep track of the number of screens which have been displayed (the first screen starts at 16520, the second at 16560, the third at 16600, etc.). When an error is found, determine the address of the error and abort the program by entering a non-numeric character. Then POKE the correct value into this location. Repeat step 4.
6) With the machine code implanted in the first REM statement, enter lines 5 through 1200 of Listing 1. This will overwrite Listing 2 which is not needed any more.
7) SAVE at least one copy on tape.
8) The program can now be RUN.
Program Operation
Before RUNning the program, connect the amplifier board to the ear input of the computer. Remove the plug from the ear jack of the tape recorder and place it into the amplifier board jack. For convenience, you may also want to disconnect the mic cable from the recorder. The amplifier power switch can now be turned on.
RUN the program. The screen should appear as shown below:
MENU
1. VOICEPRINT DISPLAY
2. VOICEPRINT FILE
3. RECOGNITION
4. CLEAR FILES
5. DISPLAY STRING FILE
6. STOP
INPUT SELECTION
Any selection can be made at any time by entering only the corresponding command number. However, we will discuss the commands in the numbered order.
Voiceprint Display
Option 1 provides a pseudo frequency spectrum of any vocalized word or sound. After selection, a machine code routine is entered which monitors the ear input. Since this routine is designed to wait indefinitely for an input signal (a sound), the time between command selection and the actual signal input is not critical.
The routine samples the input 255 times or until a pause (silence) of at least 0.75 seconds is detected. The acquired data is then manipulated to form the histogram.


The histogram consists of 255 individual frequency channels, although only 64 can be displayed at one time. The left and right arrow keys (5 and 8, respectively, without shifting) permit other channels to be observed by shifting the display. The histogram is plotted highest to lowest frequency going from left to right. The y axis is the number of occurrences of a particular frequency (or channel). In this manner, a voice print is created. Data similar to that displayed in the histogram makes the rest of the program work. Typical voice prints for the words “six” and “four” are illustrated in Figures 3 and 4. Major differences in the voice prints of the two words are readily apparent. Due to the limited amount of data which is acquired, the system is best suited to single syllable words.
After making sure the amplifier board is connected and turned on, bring the microphone approximately two to three inches away from your mouth. Type 1 for the command selection and press ENTER. The screen should go blank. Now say a word naturally, but firmly. The screen should immediately appear with a voice print histogram and the query “AGAIN? (Y/N)”. If nothing appears, gently tap the microphone. An almost blank histogram should appear. If still no response, remove the plug from the amplifier board and insert it into the cassette player ear jack. Then play a previously recorded tape (program, music, voice, etc.) at maximum volume setting. If a histogram does not appear, the amplifier board has a problem. Recheck your work; look for solder bridges and “cold” solder joints.
In response to “AGAIN? (Y/N)” enter Y to input and display another voice print or N to return to the main menu. Try different words and sounds. Pure tones, such as a crisp whistle, produce sharp histograms. Noisy phonemes, e.g., the “f” in four, produce a broader frequency spectrum.
After experimenting a while, you may have noticed the lack of data in the lower frequency channels. In fact, it is rare to find data below the 64th channel (where the 1st channel represents the highest frequency). This is due to the filtering characteristics of the computer’s ear input circuitry. Essentially, the circuit performs as a high pass filter which significantly attenuates low frequency signals (below approximately 300 Hz). It is not surprising then that the lower range of the histogram appears blank. We employ this knowledge further by using only the first 64 channels for voiceprint file creation and recognition. This significantly saves both processing time and memory.
Voiceprint File.
Option 2 asks you to type in the word (up to 10 letters long) that you wish to have recognized.
Then a file position is requested for storing the string. There are ten file positions, each one corresponding to a word (or sound). Any string and voice print file entry may be replaced at any time, with no effect on the others.
After you enter a file position (1 through 10), the program waits for you to situate the microphone comfortably, preferably so that you can see the screen. Pressing ENTER continues the program.
When the screen goes blank, pronounce the word which was input as a string. The screen displays a 1 and goes blank. Say the word again. The screen responds with a 2, and goes blank. Continue this repetition of the word for a total of eight times. Do not begin pronouncing the word until the screen goes blank. After the eighth entry, “AGAIN? (Y/N)” will appear. Entering Y permits you to create another string and voiceprint file entry, N returns you to the main menu.
The reason for repetition is to create an “average” voice print for a particular word (or sound). You are actually “teaching” the computer to recognize a word or phrase. This significantly enhances the recognition ability of the system, but it also makes the recognition dependent upon the speaker and, as I somewhat embarrassingly discovered, room acoustics. So do not attempt to demonstrate the system to your users group (which may meet in a large classroom) with a set of voice prints you made in your paneled and carpeted den. Rather, make a set of voice prints in the location where the demonstration is to be made.
Recognition
Immediately after you input 3 for the recognition command, the program waits for voice input. This is indicated by a blank screen. Upon sensing an input, voice prints are compared and the string corresponding to the “best” matching voice print is displayed. This display appears for a period of time determined by the PAUSE statement in line 625. After this PAUSE another voice (sound) input is awaited.
To exit the recognition routine, press any key (except BREAK). The program will return to the main menu.
Clear Files
Option 4 clears all entries in both the voice print and string files.
Display String File
Option 5 displays the string file. This provides assistance in locating particular file entries before replacement or reentry.
Stop
Option 6 is self explanatory.
General Comments
As to be expected, the more dissimilar sounding the words to be recognized, the more accurate the system is in selecting the correct word. In other words, homonyms are out. This is a problem for a language such as Basic where the commands “for” and “four” and “to” and “two” are frequently encountered. Context becomes important in these cases.
The DIM statement in line 10 serves no other purpose other than moving E-LINE beyond the area where voice print files are created and stored. This permits a SAVE command to save existing voice print files on tape. To SAVE the voice print files, change line 10 to:
10 DIM C(1412)
then RUN the program. Voice print files will now be SAVEd with the program. After LOADing a program which contains voice prints, start with a GOTO 20 command. The RUN command will first clear the variable area, which includes the voice prints.
A Few Last Words
After experimenting for a while, you may wonder how the program works. A complete assembly listing along with a detailed explanation of each machine code routine and a commercially reproduced tape of the speech recognition program are available from G. Russell Electronics.
I hope this article will stimulate you into making the simple amplifier and trying the program. A project like this can open your eyes as well as your computer’s ears.
G. Russell Electronics, RD 1, Box 539, Center Hall, PA 16828, (814) 364-1325, has available the documentation and program cassette for $9.95; the amplifier kit with the documentation and program cassette for $29.95; the amplifier assembled with the documentation and program cassette for $34.95; the bare silk screened circuit board for $4.95. All orders postpaid; MC/Visa accepted.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.