2. Simple words & phrases
You may keep the keyvoices on as long as you want, but you may find them a nuisance after a while, so enter:
LET keys=0
And you will find that the keyvoices have vanished. Try entering:
LET keys=1
And they reappear again. What you have done is to use a "reserved variable" to tell the unit what to do - the variable "keys" is "reserved" for the unit's use. You can put this in a program line, too - try entering this program:
10 LET keys=0
After running this, the keyvoices are disabled again.
Once you have enabled or disabled the keyvoices, they remain either on or off until you enter a "LET keys=" command, either in a program line or entered directly as a command (note that the keyvoice status is preserved even after a NEW). There is another reserved variable, s$, (standing for "speech string") which is used for generating user-defined speech.
Try entering the following:
LET s$="he(ll)(oo)"
You will hear the unit say "hello" (if you do not, type it in again, checking that you get all the brackets in).
Now try entering this program:
10 LET s$="he(ll)(oo)": PAUSE 1
Because the way in which the MicroSpeech works, you MUST put a PAUSE statement after each "LET s$=" statement in a program to make sure that the unit detects each s$ as it occurs (PAUSE 1 will do).
If you RUN this program, you will again hear the word "hello". Every time you create a new s$, the contents of the string are examined by the allophone interpreter and, if the syntax is correct, the allophone symbols are converted into speech code and placed in a "buffer" (a sort of queue) near the top of memory. The code in the buffer is then automatically outputted to the speech chip without any further intervention from your BASIC program.
You BASIC program can go away and do other tasks once the speech has been stored, so you can fill the buffer up and leave it to get on with outputting speech whilst you type in some data, for instance, or add more speech to the buffer.
User-defined speech has higher priority than key voices, so that if a sentence is being spoken and you press a key, the keys will not voice, even if they are enabled, until the buffer has been emptied.
The unit has a self-diagnostic facility which reports on the status of the speech you tried output. RUN the above program again, and then enter:
PRINT s$
The computer will report back with:
*e(ll)(oo)
The asterisk obliterating the first character tells you that the allophone symbols contained in s$ were syntactically correct and that they were converted into speech code and loaded into the buffer for output. Now try changing the program to read:
10 LET s$="he(ll)!(oo)": PAUSE 1
No speech will be generated if you RUN this as the exclamation is a "illegal" character. RUN the program, then type in:
PRINT s$
And you will get the following report:
?e(ll)!?oo)
The query (?) obliterating the first character tells you that there was an error in the string, and the second query shows you where the error occured. In the case of an error occuring on the last character of the string, the second query obliterates it.
If you BREAK into a program whilst the voice is speaking the voice ceases at once - what is not so obvious is that any "report" given by the Spectrum other than "OK" will also have this effect: e.g., STOP statement, Out of DATA, RETURN without GOSUB, etc. This is to ensure that if there has been an error in a program which may have left you with a buffer full of data you will not have to wait for the buffer to empty itself - remember a buffer only 200 bytes long can hold over 30 seconds of speech.
You have seen four examples of the allophone symbols used already, and you will probably be wanting to try constructing you own words and phrases. When you feel that you are familiar with the use of the reserved variables, go on to the next chapter, where the whole allophone set will be introduced.