* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Program * MVREADER.PRG * * System * Micro/Voice for Clipper Summer '87 and 5.0 * * Version * Version 2.00 * * Library * MVCLIP87.LIB/MVCLIP50.LIB - 11/01/90 2:00a * * Author * Steve Badaracco * * Notice * (c)1990, DataBlaze Solutions, All Rights Reserved * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * --- NOTE --- * * As explained in the DOC, the pitch (speed-delay) is important to the * * clarity and understandability of the speech you will hear. In the call * * to v_init() below, you will notice a speed-delay of 23, which is about * * right for an IBM PS/2 Model 50Z or 55SX. Unless you are running this * * program on one of these two machines, you will need to adjust the * * speed-delay to suit the hardware. Remember, a HIGHER number LOWERS the * * pitch, to compensate for a FASTER machine. * * * * Syntax: MVREADER filename.ext [ N ] <--"N" (optional) = No phonemes. * * This program demonstrates reading text from a disk file with Micro/Voice. * * Try MVREADER.TXT, which contains words defined in the mini-dictionaries. * * When reading text from a file, it is especially important to have a * * dictionary present, as we have done here. A full dictionary is available * * to registered users of Micro/Voice, as well as a program which allows * * you to build a custom dictionary; see the DOC file for details. * * * * To compile (requires The Clipper Compiler, Summer '87 or 5.0 Version): * * CLIPPER MVREADER * * * * To link using Microsoft Overlay Linker Version 3.x (Summer '87 syntax): * * LINK MVREADER,,NUL,CLIPPER+EXTEND+MVCLIP87/SE:256 * * To link using Turbo Link Version 1.x (Summer '87 ONLY): * * TLINK MVREADER,,NUL,CLIPPER+EXTEND+MVCLIP87 * * To link using PLINK86plus Version 2.24 (Summer '87 ONLY): * * PLINK86 FI MVREADER LIB CLIPPER,MVCLIP87,EXTEND * * To link using Blinker Dynamic Overlay Linker (Summer '87 syntax): * * BLINKER FI MVREADER LIB CLIPPER,MVCLIP87,EXTEND * * * * To link using .RTLink Version 3.1x (Clipper 5.0 ONLY): * * RTLINK FI MVREADER LIB MVCLIP50 (assumes LIB= in DOS environment) * * To link using Microsoft Overlay Linker Version 3.x (Clipper 5.0 syntax): * * LINK MVREADER,,NUL,MVCLIP50/SE:256 (assumes LIB= in DOS environment) * * * * To run the demo on the sample text file: * * MVREADER MVREADER.TXT * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * parameters filename, showphonemes * FILENAME is the text file to be read (no wildcards) * SHOWPHONEMES (Y or N .. defaults to Y): If N, then phoneme strings are * not echoed to the screen. if pcount() = 0 * No parameters received on the DOS command line ************************************************ ? 'Filename to be read must be specified on the command line.' ? quit elseif !file(filename) * First parameter was not the name of an existing file ****************************************************** ? 'File not found.' ? quit elseif "?" $ filename .or. "*" $ filename * Did you know that Clipper's file() function processes wildcards? ****************************************************************** ? 'No wildcards allowed.' ? quit elseif v_init( 'system01.dct', 'mycustom.dct', 1, 23, 2 ) # 0 * Good Micro/Voice initialization settings for PS/2 Model 55SX * You will want to adjust these for the machine you are working with. * Run the demo program MVDEMO to experiment with interactive adjustment * of the Micro/Voice speed settings. *********************************************************************** ? 'Voice initialization error: data file(s) not found.' ? quit elseif memory(0) < 12 && a good round number * Since we are using fread() to fill a buffer with the ENTIRE file * for our test, let's make sure there is enough memory to do so. ****************************************************************** ? 'Not enough memory to read a file.' ? quit endif * Print program information on the screen ***************************************** ? "Micro/Voice text file reader demo for Clipper Summer '87 and 5.0" ? 'Reading file: "&filename." ... to cancel.' * Open the file * Remember ... this is just a demo; we area assuming this is * a text file. A binary file would, of course, break it. ************************************************************ handle = fopen( filename ) if handle < 0 ? 'Error opening file "&filename.".' ? quit endif * Read up to 10K for our demo ***************************** thedata = space( 10240 ) fread( handle, @thedata, 10240 ) fclose( handle ) thedata = trim( thedata ) * Process second command-line parameter: blank or "N" are acceptable ******************************************************************** showphonemes = if( type("showphonemes") = "U", .T., ; if( upper( showphonemes )="N", .F., .T. ) ) * Main processing loop -- until end of text or Esc key is pressed ***************************************************************** do while ! empty( thedata ) .and. inkey() # 27 * Parse out next logical line ***************************** crlf = at( chr(13)+chr(10), thedata ) crlf = if( crlf=0, len( thedata ) + 1, crlf ) current = alltrim( subst( thedata, 1, crlf-1 ) ) thedata = subst( thedata, crlf+2 ) * Don't bother processing blank lines ************************************* if ! empty( current ) * Pack the line for Micro/Voice ******************************* packed = v_wpack( current ) * Display text as read from file ******************************** ? current * Display the phoneme string equivalent * (if second argument is not "N") *************************************** if showphonemes ? v_unpack( packed ) ? endif * Speak it! *********** v_pkspeak( packed ) endif enddo quit