PROGRAMMING THE TI
C. Regena
The Singing Computer
If a computer can speak and can play music, can it sing? This month, I'll try to make the TI sing. First, to make the computer talk you need the TI Speech Synthesizer, a small peripheral device that attaches to the right side of the console. To use the speech synthesizer, you also need a command module that is made to provide speech.
To do your own programming with speech, you also need a command module. Right now the modules available are Speech Editor, TI Extended BASIC, and Terminal Emulator II. Terminal Emulator II is the easiest to work with because you can type any word in and the computer will pronounce it phonetically. Speech Editor and Extended BASIC use CALL SAY commands and have limited vocabularies.
I've had several letters from people wondering why certain phrases don't work. To make the computer say a phrase, such as Texas Instruments, use the number sign (SHIFT 3) before the phrase. For example, CALL SAY ("#Texas Instruments").
Unlimited Speech
A bit of history here—the original speech synthesizer was designed to use the words in the Speech Editor and Extended BASIC lists. Inserts were going to be made available that had different vocabularies (that's why some of the speech synthesizers have a lift-up lid). Then the Terminal Emulator II command module was invented, which provides unlimited speech, and inserts to the synthesizer were no longer needed.
Extended BASIC has also gone through at least one revision. I assume there are very few of the original version around because most users exchanged the original module for the second version as soon as they could. The first version did not support repeating keys and was notorious for "locking up" the computer. There were also some problems with using IMAGE statements.
The Terminal Emulator II command module has a dual purpose. In fact, it's called Terminal Emulator II because it is used to make your TI act as a terminal for another computer. For telecommunications you can use your TI-99/4A with an RS-232 Interface and a telephone modem, plus the Terminal Emulator II command module.
Pages 33-42 of the Terminal Emulator II instruction manual describe how to use speech. There are two main ways to use speech, "text-to-speech" and allophone speech. I use the text-to-speech method because all you have to do is spell the text phonetically. The allophone speech can be more exact because you can specify certain sounds. The manual contains a list of allophone numbers with their sounds plus a few sample programs of how to use this method.
Singing Requires Experimentation
Working with speech in a program takes a lot of experimentation. First, you need to try different spellings to get the computer to properly say what you want it to say. Then you can try different inflection symbols, ^, -, and >. These are used to change inflections and stress points, but they can also change the tone of the voice. You can also add different pause symbols for different sounds and contours. These symbols are the comma, period, semicolon, colon, exclamation point, question mark, and space. Finally, you can alter the pitch and slope—this is what I do to make the computer sing.
To create speech, you need the following statement:
OPEN #1 : "SPEECH", OUTPUT
You may use any number after the number sign, just as in opening other types of files. Later, when you want the computer to speak, just use a command such as
PRINT #1 : "MY NAME IS SINNDY."
The pitch is how high or low the voice sounds and can be a number from 0 through 63. Zero is a whisper, 1 is the highest pitched voice, and 63 is the lowest pitched voice. The slope is the rate at which the pitch changes in a spoken phrase. The slope may be a number from 0 through 255. For the best results, the manual recommends a slope 3.2 times the pitch. There are certain combinations of pitch and slope that will not be accepted. The default values of pitch and slope are 43 and 128. To change the pitch and slope, use the format //xx yyy where xx is the pitch period and yyy is the slope level. There must be a space between the numbers. An example in a program statement would be: PRINT #l:"//30 96"
Changing The Pitch
The following is a sample program that illustrates how the pitch and slope change the sound of the voice. I am trying different pitches from 0 to 63 (and STEPping by 2 so it won't take forever). The slope S is calculated by taking the recommended factor of 3.2 times the pitch. Remember, you may try different slopes if you prefer. B$ combines the double slashes with the pitch, a space, and the slope, so line 170 can set the pitch and slope. Line 180 then speaks the phrase.
100 REM PITCH AND SLOPE 110 CALL CLEAR 120 OPEN #5 : "SPEECH", OUTPUT 130 FOR P = 0 TO 63 STEP 2 140 S = INT(P * 3.2 + .5) 150 B$ = "//"&STR$ (P);&" "&STR$ (S) 160 PRINT B$ 170 PRINT #5 : B$ 180 PRINT #5 : "TRY THIS TEST." 190 NEXT P 200 END
Since other statements can be executed while a sound is playing, you can play a tone, then say a word. By changing the pitch and slope numbers for the speech, you can make the voice go higher or lower, and program a singing computer.
Remember—I mentioned that working with speech involves a lot of experimentation. Singing takes even more time because there are many parameters that vary with each new tone. After you change the pitch and slope, you can try the inflection symbols and the punctuation marks to vary the voice even more. The TI with Terminal Emulator II can really create synthesized speech that sounds pretty good.
Teaching The ABCs
"Alphabet Song" illustrates simple singing on the computer. However, I did not spend a lot of time fiddling with the program and trying different things to make the speech sound better. You may want to try spelling out the letter as a word, and you may want to add the inflection symbols and punctuation marks. I used different pitches for the singing, but kept the slope numbers just 3.2 times the pitch. You could vary these numbers to get a more human sound and a better singing voice.
My little boy has played a lot with the Early Learning Fun command module. One section teaches the letters of the alphabet, and the child finds the letters on the keyboard. My son is quite proficient at this and knows the names of the letters, but I realized he'd learned them in a random order. Most children learn the alphabet from the ABC song, but I had never sung it to him. I decided I'd let the computer sing it to him.
Lowercase letters are used in the program because my son already knows the capital letters and really needs a little more practice with the lowercase letters. Schoolteachers often recommend learning the lowercase letters right along with the capital letters, and all beginning reading is in lowercase letters.
Lines 120-200 define the lowercase letters. If you have saved the lowercase letters program from my August 1983 column, you can load that program, delete the PRINTing lines, then continue typing this program. If you have any problems running this program, the most likely cause is in typing the data in lines 160-200. Your actual error message will cite line 130 or line 140, but those lines are dependent upon the DATA statements. Do not type a comma at the end of a line.
Extra Option
To hear the singing you will need the TI Speech Synthesizer and the Terminal Emulator II command module. When you turn on the computer with the module plugged in, press any key to start, then press 1 for TI BASIC and program as usual. To run the program without speech, you can select option 2 when the program starts. In this case, you don't need the module or the speech synthesizer.
If you choose no speech, the variable SP will equal 2. All the IF SP = 2 THEN ... statements skip over commands that require the Terminal Emulator II module. The CALL SOUND statements play the tune. I used only one note; you may add accompaniment if you'd like. After the tone is played, the letter is sung. The CALL HCHAR or CALL VCHAR statements then place the letter on the screen.
Lines 1880–1910 wait after the song is over until the user presses ENTER, then the song is repeated.