Talk to your Spectrum If the strain of pushing keys is telling, J D M Edwards' program lets you sit back and relax. Before entering the main Basic program the machine-code routine should be entered using the following Basic program. 10 FOR n=USR "r" TO USR "u" 20 INPUT a 30 POKE n,a 40 NEXT n After entering the program, type RUN and press ENTER, then enter the numbers in the left-hand column taking / as ENTER. The mnemonics are included for machine-code enthu- siasts. 33/56/92/ LD HL,(5C38) 62/0/ LD A,00 119/ LD (HL),A 6/255/ LD B,FF 219/250/ IN A,(FA) 254/255/ CP FF 40/1/ JR Z 01 52/ INC (HL) 16/247/ DJNZ -9 201/ RET 0/0/0/0/0/0/0 NOP (*7) The machine code acts as a crude frequency counter by loop- ing around 255 times and adding 1 to the location 23608 each time it hears a noise through the ear socket. We are therefore left with a number between 0 and 255 at location 23608 each time we call the routine. This number will cor- respond to the frequency and, to some extent, the amplitude of the sound entering the ear socket when the routine was running. To use the program you will need some kind of input to the ear socket; you could use a radio or a cassette recor- der. To use the main Basic program you will need some way of connecting a microphone to the ear-socket, via an ampli- fier so that the computer can analyse your voice dynami- cally - as you speak. Sound source To use the program, plug the ear lead on the Spectrum into the ear lead of your sound source as shown in the diagram, figure 1. If you want to see the program working but cannot connect a microphone to your Spectrum, then enter the following short Basic program. 10 FOR n=1 TO 175 20 LET a=USR USR "r" [Yes, two USRs.] 30 PLOT 0,n 40 DRAW PEEK 23608,0 50 NEXT n 60 CLS 70 GO TO 10 Type RUN and ENTER and gradually turn the volume of your sound source up until you see a fine bar graph across about one quarter of the screen; your computer is now displaying the sound that is going into the ear socket. If you can connect a microphone to your computer then try this Basic speech-analysis program. After entering it, type RUN and switch on your microphone. Enter how many words you want - I suggest two for your first try - then enter which word you want to enter first. You should see the words "Speak after tone" appear, accompanied by a beep. The machine will then wait for a sound in the mike before it starts inputting information, so you can take your time before saying your word after the tone has stopped. When you have said your word, sit back and wait until the machine asks for the name of the word. After entering this you will be given two graphs at the moment identical and will be asked if you want to learn or continue. Select learn and you will again be faced with the prompt "Which sound?". This time enter 2 and repeat the process. For better results repeat each word several times - not on the same analysis, but respond with each number several times to the prompt. This will be averaged out to provide a more accurate result. Word matching Having repeated each word several times, respond with Continue to the prompt and say one of the words after the tone. The Spectrum will sort through its files and print the word nearest to yours. Although slow, this method has a good success rate and could be rewritten in machine code to save time. ___________________________________________________________ _______________________ | | #Ear #Ear +-------------+ +-------------+ +-------------+ | Sound | | ZX Spectrum | | Source | +-------------+ +-------------+ Figure 1. ___________________________________________________________ [ The programs on the TZX that goes with this text file are in a different order than described above, but the programs themselves are (almost) the same. First comes the speech analyser, then the machine code, then the short test pro- gram from the article text, and finally the machine code again. The only difference between the programs on the TZX and the programs as published in Your Computer is that the ones on the TZX auto-load the machine code. I haven't been able to test these programs using a micro- phone, but they seem to work well enough with WAV files. Richard Bos, February 2012 ]