bill@utastro.UUCP (William H. Jefferys) (01/15/87)
Lightspeed C v. 2.01 supports Macintalk with a library and header file.
Thanks to some pointers from Dave Bursik (db@cbosgd.UUCP) and
Tom Speeter (vax135!ths@clyde.UUCP) I was able to get a very simple
program working under Lightspeed C that uses Macintalk. I used
Simpletools to define the user interface and main event loop, but
you can use any technique you want for this. The main ideas are from
an article by Bob Perez in MacUser, March 1986, pp. 104-110 (his
program is in Aztec C). Tom's article should be consulted for further
information.
Bill Jefferys
University of Texas
------------- Rippety Tear Snip Snip --------------------------------
#include <MacinTalk.h>
#include <MemoryMgr.h>
SpeechHandle theSpeech;
Handle spOut;
quitproc()
{
DisposHandle(spOut); /* Dispose of handles and */
SpeechOff(theSpeech); /* Turn Macintalk off before exiting. */
exit(0);
}
sayproc()
{
long len;
char str[255];
strcpy(str,"");
prompt("Type something to say.",str); /* Get a phrase */
len = (long)strlen(str);
CtoPstr(str);
Reader(theSpeech, str, len, spOut); /* Convert to phonemes */
MacinTalk(theSpeech, spOut); /* Say it. */
}
main()
{
SpeechErr err;
simpletools("Talk"); /* Initialize everything */
menu("File","Quit/Q",quitproc); /* Set up menus */
menu("Actions","Say/S",sayproc);
spOut = NewHandle(0L); /* Allocate handle */
if((err = SpeechOn("\p",&theSpeech)) != noErr)
exit(0); /* Turn Macintalk on */
for(;;) /* Main event loop */
simpleevents();
}bill@utastro.UUCP (William H. Jefferys) (01/16/87)
Contrary to my assumption, the Macintalk routine Reader() apparently expects a "C" formatted string, not a Pascal string. Therefore, the call to CtoPstr() in my previously posted program should be eliminated. Bill Jefferys
espen@well.UUCP (01/17/87)
#include <stdio.h>
#include <quickdraw.h>
#include <memory.h>
#include "macintalk.h"
int i;
char linein[5120],exceptfile[64];
Handle output;
SpeechHandle theSpeech;
FILE *f,*fopen();
main(argc, argv)
int argc;
char **argv;
{
exceptfile[0] = 0;
i = SpeechOn(exceptfile, &theSpeech);
/*Open the speech driver and the READER English to phonetics
conversion package with the default
pronounciation ruleset.*/
if (i == 0) { /*If error, go away*/
f = fopen(argv[1],"r"); /*Open the English input file.*/
i = fread(&linein[0],10,512,f);
/*Read 10 blocks (5120 chars) from the input file.*/
output = NewHandle(0L); /*Create a handle for the phonetic
output. Reader will dynamically grow this handle
as needed.*/
/*Convert the English text to phonetic codes.*/
i = Reader(theSpeech, &linein, 6000L, output);
i = MacinTalk(theSpeech, output); /*Say it.*/
SpeechOff(theSpeech); /*Close the speech driver.*/
DisposHandle(output); /*Release the output handle*/
close(f); /*Close the input file.*/
}
}