10 DATA 0,0,0 0,0,0,0,62,15,0,0,0 0,0,0,0 20 A = 33024 30 FOR X =0 TO l 5: READ D 40 POKE A+ X,D 50 NEXT 55 REM 3-11 ***SET BOTH SOUND CHIP POINTERS TO POINT TO THE ADDRESS OF THE SOUND DATA, 33024. 60 POKE 8,0:POKE 9,129 62 POKE 10,0:POKE 11, 129 70 FOR Z= 1 TO 5 75 REM ***CHANGE THE SOUND DATA IN MEMORY TO THE FIRST SOUND AND PLAY IT THROUGH THE FIRST SPEAKER WITH A CALL TO THE TABLE ACCESS ROUTINE. (NOTE THAT 32768 IS THE ROUTINE FOR THE FIRST CHIP.) 80 POKE 33024,145:POKE 33025,0:CALL 32768 90 FOR T = 1 TO 342:NEXT T 95 REM ***CHANGE THE SOUND DATA IN MEMORY TO THE SECOND SOUND 100 POKE 33024,86:POKE 33025,1 105 REM ***TURN OFF THE FIRST SOUND CHIP WITH A CALL RESET AND PLAY THE SECOND SOUND THROUGH THE SECOND SPEAKER WITH A CALL TO THE TABLE ACCESS ROUTINE. (NOTE 32796 IS THE ROUTINE FOR THE SECOND CHIP.) 110 CALL 36897:CALL 32796 120 FOR T=1 TO 342:NEXT T 125 REM ***CALL RESET2 TO SHUT OFF THE SECOND SOUND CHIP 130 CALL 36941 135 REM ***IF Z IS LESS THAN 5, PLAY THE SEQUENCE AGAIN 140 NEXT 160 END In this last example, one tone of the siren is played through one speaker and the other tone through the second speaker. Other variations are also possible. 3-12 THE SPEECH CHIPS The Text To Speech Rule Editor is used to develop words or phrases for use in your programs. Enter the Test Node from any character rule table and type in the word or phrase you wish to use. Adjust the pronunciation, using the parameter controls and stress markers. Once you are satisfied with the quality of speech, save the word or phrase by typing control-S from the Test Mode. Name the file using a maximum of eight characters, beginning with a letter (A-Z). The word or phrase saved is a composite file of all the speech parameters. However, the composite file contains only data. This data is similar to the 16 sound parameters needed to produce a sound effect. While the sound parameters are finite, the speech parameters consist of four parameters for each phoneme code generated to produce the speech. If a word consists of 20 phoneme codes, then the composite file of that word contains 100 parameters (including the phoneme codes). From the Rule Editor, a word or phrase is spoken using the Text To Speech Algorithm. Outside of the Rule Editor, another type of program must be employed to generate speech. The Text To Speech Algorithm is no longer necessary, because the conversion from text to phoneme codes has already been done and saved. A program called the Composite Driver, included on the demonstration disk, acts as a messenger and transmits speech codes to the speech chip from the composite data file. The Composite Driver is similar in concept to the Table Access Routine. The Table Access Routine retrieves data and sends it to the sound chip. The Table Access Routine knows where the data is located by using a pointer. The Composite Driver also has a pointer which tells it where the speech data is located. These similarities standardize the programming method employed in generating both sound and speech. Let's enhance a short program with speech. Load the following files in memory prior to running the sample program or at the beginning of the sample program: BLOAD COMPOSITE DRIVER BLOAD < composite data file name >, A < address in memory ) The composite data file may be stored in any unused memory space. The 3-13 pointer location for the beginning address of the speech data is stored in location 249 and 250. The high byte of the address is stored in 250 and the low byte is stored in 249. If you are unfamiliar with high and low bytes, the high byte is obtained by dividing the address by 256 and the low byte is the remainder of this division. If the data is stored at 33024, then the high byte is 33024/256 or 129. The low byte is zero since there is no remainder. The following phrase was created using the Rule Editor and saved on the demonstration disk as PHRASE 1: WITH MOCKINGBOARD YOU'LL NEVER BE SPEECHLESS Type in the program below on your copy of the demonstration disk. If you are using a fresh disk, copy the COMPOSITE DRIVER and PHRASE 1 files onto your disk. IO HOME 20 D$ = CHR$(4) 25 REM ***LOAD COMPOSITE DRIVER 30 PRINT D$"BLOAD CONPOSITE DRIVER" 35 REM ***LOAD THE DATA FILE PHRASE 1 AT LOCATION 35072 40 PRINT D$"BLOAD PHRASE 1, A 35072" 45 REM ***TELL COMPOSITE DRIVER WHERE THE DATA FILE PHRASE 1 RESIDES. CONVERT 35072: HIGH BYTE-INT (35072/256) OR 137, PUT IT IN LOCATION 250; LOW BYTE-INT (35072/256) - 137 OR 0, PUT IT IN LOCATION 249. 50 POKE 249,0:POKE 250, 137 55 REM ***TELL COMPOSITE DRIVER TO BEGIN SPEAKING. COMPOSITE DRIVER IS LOCATED AT 27904. 60 CALL 27904 70 END This program will speak the entire phrase and then end at line 70. In most cases, the program would not speak and then end, it would continue on with other tasks. If this program did not end at line 70, the speech could be interrupted prematurely by an input from the keyboard or program code. In order to protect against such an interruption, the program should check to determine if the speech chip is finished speaking. 3-14 When MOCKINGBOARD speaks, a busy flag is set. This flag is located at location 255. When MOCKINGBOARD is finished speaking, the flag is cleared, Your program can monitor this flag. A standard BASIC programming command called PEEK may be used to look at the contents of this location. Type the following lines into the above program. Delete line 70. Save the new version of the program and run it. 80 VTAB 6:HTAB 1:PRINT "WOULD YOU LIKE TO HEAR IT AGAIN?"; :GET A$ 90 IF A$ = "Y" THEN GOTO 60 100 IF A$ =- "N" THEN GOTO 120 11O GOTO 80 120 END The question, "WOULD YOU LIKE TO HEAR IT ACAIN? " appears on the screen almost at the same time as the speech begins. If you respond to this question before the speech ends, you will interrupt it. Try it. Press the Y key several times in quick succession. The phrase is not allowed to finish until you stop pressing the key. To prevent this, insert the following lines in this program. Save and run it. You will no longer be permitted to interrupt the speech. 65 REM ***CHECK TO SEE IF FINISHED SPEAKING. IF NOT, KEEP CHECKING UNTIL IT IS. 70 IF PEEK (255)> 0 THEN 70 To incorporate more than one phrase in your program, load each file at the beginning of the program. Load each one at a different location, so you will be able to call them at will. Change the pointers, 249 and 250, to point to the phrase you wish spoken just before CALLing the composite driver. Let's try it with PHRASE2, which says: I LOVE TO TALK. This time, let's print the phrases on the screen. 10 HOME 20 D$ =- CHR$(4) 30 PRINT D$"BLOAD COMPOSITE DRIVER" 40 PRINT D$"BLOAD PHRASE1, A 35072" 42 REM ***LOAD THE SECOND PHRASE AT 36864 3-15 45 PRINT D$"BLOAD PHRASE2, A 36864" 47 PRINT "WITH MOCKINGBOARD YOU'LL NEVER BE SPEECHLESS" 50 POKE 249,0: POKE 250,137 60 CALL 27904 70 IF PEEK (255)>0 THEN 70 80 VTAB 6:HTAB 1:PRINT "WOULD YOU LIKE TO HEAR IT AGAIN?"; :GET A$ 90 IF A$ = "Y" THEN GOTO 60 100 IF A$ = "N" THEN GOTO 120 110 GOTO 80 120 VTAB 10:HTAB 1:PRINT "WOULD YOU LIKE TO HEAR ANOTHER PHRASE?"; :GET B$ 130 IF B$ = "Y" THEN GOTO 152 140 IF B$ = "N" THEN GOTO 170 150 GOTO 120 152 VTAB 10:HTAB 1:PRINT "I LOVE TO TALK!" 155 REM ***CHANGE THE POINTERS TO POINT TO PHRASE2 AT 36864 :HIGH BYTE = INT (36864/256) OR 144, PUT IN 250; LOW BYTE = 36864/256-144 OR 0, PUT IN 249. TELL COMPOSITE DRIVER TO SPEAK THIS PHRASE. 160 POKE 249,0:POKE 250, 144:CALL 27904 170 END Save and run this program. If you would like to try out a different phrase, change line 40 and/or 45 to load your file. Don't forget to change the phrase printed on the screen in lines 47 or 152. Why not make all the prompts in this program speak? USING TEXT TO SPEECH AND THE RULE TABLE IN YOUR PROGRAM The above programming method is a very convenient way to generate speech, provided you know what vocabulary will be required in your program. This is not always possible or desirable. You may wish to have a person using your program type in his own responses. These words could also be spoken by MOCKINGBOARD. However, unless the response is limited to a predefined vocabulary, words not previously coded will be left unsaid. Another method of generating speech will allow MOCKINGBOARD to speak an unlimited vocabulary. 3-16 This program incorporates the Text to Speech program included on the demonstration disk. It uses a table of rules (also included on the disk to convert text into speech. The text may consist of characters typed from the keyboard or characters assigned to a string variable. It may also be text saved in a text file. If your program is very large, this method may not be economically implemented, due to the size of the rule table. However, if you can anticipate the vocabulary that may be used in your program, including responses from the user, an empty rule table may be used to build a custom list of words, The empty rule table will allow you to enter only rules which may pertain to your program. If you prefer, you may also trim the current rule table to a size more suitable to your program and save the revised version under another name. Any rule table may be included in your program along with Text To Speech. A sample program using this method is given below. Regardless of whether you are converting input from the keyboard or assigning it to a string variable within your program, you must assign the input to the variable MB$. The program, which Text To Speech uses to retrieve the text data, looks for this variable. This program is called MB$ GETTEXT. IO HOME 20 D$ = CHR$(4) 30 PRINT D$"BLOAD TEXT TO SPEECH" 40 PRINT D$"BLOAD MB$ GETTEXT" 45 REM ***LOAD THE RULE TABLE 50 PRINT D$"BLOAD MKB:RULE. TABLE" 60 PRINT D$"BLOAD NKB:RULE. LENGTH" 70 PRINT D$"BLOAD MKB:RULE. INDEX" 75 REM ***ASSIGN THE PHRASE TO BE SPOKEN TO MB$ 80 MB$ = "WITH MOCKINGBOARD YOU'LL NEVER BE SPEECHLESS" 85 REM ***TELL TEXT TO SPEECH TO BEGIN SPEAKING THE PHRASE 90 CALL 26123 95 REM ***CHECK TO SEE IF FINISHED SPEAKING. IF NOT, KEEP CHECKING UNTIL IT IS. 100 IF PEEK (255)>0 THEN 100 110 END 3-17 MKB:RULE is the standard rule table designed by Sweet Micro Systems. You may replace this with your rule table file name. The .TABLE, .LENGTH and .INDEX must be appended to your rule table file name. These files monitor the expansion and reduction of the rule table as well as where all the characters reside in memory. They are always updated and saved when you save a rule table. If you wish to speak a response from the user change line 80 to: 80 INPUT "ENTER TEXT: ";MB$ The INPUT statement may be any question or prompt. A-1 APPENDIX A Phoneme Chart LIST OF CONSONANT PHONEMES CODE PHONEME 1 2 3 4 EXAMPLES B 24 64 A4 E4 bat, tab D 25 65 A5 E5 dub, bud F 34 74 B4 EA fat, ruff, photo, laugh HV 2A 6A AA EA eh! HVC 2B 6B AB EB d(h)ouble HF 2C 6C AC EC hat, home HFC 2D 6D AD ED P(h)ad, fluff(h), black(h) HN 2E 6E AE EE hnh-hnh J 31 71 81 F1 job, rage K 29 69 A9 E9 kit, tick KV 26 66 A6 E6 big, gag L 20 60 A0 E0 lab, ball LI 21 61 A1 E1 plan, club, slam LF 22 62 A2 E2 bott/e, channe/ M 37 77 B7 F7 mad, dam N 38 78 B8 F8 not, ton NG 39 79 B9 F9 ring, rang P 27 67 A7 E7 pat, tap R 1D 5D 9D DD rat S 30 70 B0 F0 sat, lass SCH 32 72 B2 F2 shop, push T 28 68 A8 E8 tap, pat THV 35 75 B5 F5 bathe, the TH 36 76 B6 F6 bath, theory V 33 73 B3 F3 vow, pave W 23 63 A3 E3 why, quake Y1 04 44 84 C4 you Z 2F 6F AF EF zap, maze 00 40 80 C0 [pause] The 9 columns of code for each phoneme allow you to alter the length of any sound, and choose the version which provides the most intelligibility and natural quality. Each successive column represents a phoneme which is approximately 25% shorter than its predecessor. For most purposes, column 1 will serve as a standard value. A-2 APPENDIX A Phoneme Chart (continued) LIST OF VOWEL PHONEMES CODE PHONEME 1 2 3 4 EXAMPLES A 08 48 88 C8 day AI 09 49 89 C9 care AE 0C 4C 8C CC dad AEI 0D 4D 8D CD laugh AH 0E 4E 8E CE top, about AHI 0F 4F 85 CF father AW 10 50 90 D0 saw, caught E 01 41 81 C1 beet, be EI 02 42 82 C2 advent EH 0A 4A 8A CA leg, said EHI 0B 4B 8B CB silent ER 1C 5C 9C DC third, urn, heard I 07 47 87 C7 sit, bid O 11 51 91 D1 boat OO 13 53 93 D3 put, pull, look OU 12 52 92 D2 orb U I6 56 96 D6 boot, you UI 17 57 97 D7 poor UH I8 58 98 D8 cup UHI 19 59 99 D9 circus UH2 1A 5A 9A DA nation UH3 1B 5B 9B DB nation FOREIGN SOUNDS AY 05 45 85 C5 francais French A 3A 7A BA FA etre French or umlauted A in German E2 3E 7E BE FE schön German IE 06 46 86 C6 il French IU 14 54 94 D4 peut French IUI 15 55 95 D5 Goethe German OH 3B 7B BB FB menu, tu French U 3C 7C BC FC fiihlen German UH 3D 7D 8D FD menu, tu French Y 03 43 83 C3 y French LB 3F 7F BF FF il French Rl 1E 5E 9E DE réponse French R2 1F 5F 9F DF richtig German A-3 APPENDIX A Programmable Sound Generator Registers REGISTER DESCRIPTION DEC HEX R0 FINE TUNE 0-255 00-FF CHANNEL A TONE PERIOD R1 COARSE TUNE 0-15 00-0F R2 FINE TUNE 1-255 00-FF CHANNEL B TONE PERIOD R3 COARSE TUNE 0-15 00-0F R4 FINE TUNE 0-255 00-FF CHANNEL C TONE PERIOD R5 COARSE TUNE 0-15 00-0F R6 NOISE PERIOD ALL CHANNELS 0-31 00-1F R7 ENABLE NOISE/TONE 0-63 00-3F R8 CHANNEL A AMPLITUDE 0-16 00-10 AMPLITUDE LEVEL R9 CHANNEL B AMPLITUDE MODE SELECT 0-16 00-10 FIXED=0-15 VARIABLE=16 R10 0-16 00-10 R11 FINE TUNE ENVELOPE 0-255 00-FF R12 ENVELOPE PERIOD COARSE TUNE 0-255 00-FF ENVELOPE R13 ENVELOPE SHAPE/CYCLE CONT: ATTACK:ALT: 0-15 00-0F HOLD R14 NOT USED REGISTER VALUE NOT SIGNIFICANT R15 NOT USED REGISTER VALUE NOT SIGNIFICANT A-4 APPENDIX C Noise and Tone Enable Register (adapted from General Instrument Programmable Sound Generator Data Manual) REGISTER NOISE TONE REGISTER NOISE TONE VALUE CHANNEL CHANNEL VALUE CHANNEL CHANNEL DEC HEX C B A C B A DEC HEX C B A C B A 00 00 ON ON ON ON ON ON 32 20 - ON ON ON ON ON 01 01 ON ON ON ON ON - 33 21 - ON ON ON ON - 02 02 ON ON ON ON - ON 34 22 - ON ON ON - ON 03 03 ON ON ON ON - - 35 23 - ON ON ON - - 04 04 ON ON ON - ON ON 36 24 - ON ON - ON ON 05 05 ON ON ON - ON - 37 25 - ON ON - ON - 06 06 ON ON ON - - ON 38 26 - ON ON - - ON 07 07 ON ON ON - - - 39 27 - ON ON - - - 08 08 ON ON - ON ON ON 40 28 - ON - ON ON ON 09 09 ON ON - ON ON ON 41 29 - ON - ON ON - 10 0A ON ON - ON ON - 42 2A - ON - ON - ON 11 0B ON ON - ON - - 43 2B - ON - ON - - 12 0C ON ON - - ON ON 44 2C - ON - - ON ON 13 0D ON ON - - ON - 45 2D - ON - - ON - -end of part 6-