Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!amdahl!dlb!dana!rap From: rap@dana.UUCP (Rob Peck) Newsgroups: comp.sys.amiga Subject: Re: Simple Example Desired Message-ID: <244@dana.UUCP> Date: Fri, 16-Oct-87 13:31:07 EDT Article-I.D.: dana.244 Posted: Fri Oct 16 13:31:07 1987 Date-Received: Sun, 18-Oct-87 05:10:28 EDT References: <224@shamash.UUCP> Organization: Dana Computer, Inc., Sunnyvale, CA Lines: 123 Keywords: Translator.device Narrator.device Summary: quickie howto, perhaps amusing as well. In article <224@shamash.UUCP>, jwabik@shamash.UUCP (Jeff Wabik) writes: > This has probably been asked before, but, could someone post (or mail) a > working example using the translator and narrator devices? I've been > scratching my head for a few days here, even examining such goodies as > speechtoy.c, but with no luck. My environment is Manx 3.4 .. > > -Jeff I created this 99 line program in the hopes that it would be killer demo material. It is too short, I believe, for the sources posting hopefully qualifying as message-only status for all purposes. This is about as short and simple as you can get when dealing with the narrator and translator. To simplify it further, you could also delete the creation of rn - the message block that reads the mouths. I wanted to make the narrator sing. It sorta does it, but the syllables are too far apart to have anyone say "yes, it really does sing". Yet it does provide at least a jumping off point for folks to use (creation method: 1. open speechtoy.c source, 2. remove anything not strictly speech-related, 3. compile whats left.) I was told by Mark Barton that I'd have to get deep into the Narrator device code in order to "really" do what I wanted, since it was not designed to sing in the first place. You'll find that he was right. The test phrase, by the way, folks said "if you are going to make it sing, surely you won't want to use 'Daisy, daisy....'" Well, they were wrong. Hope it helps. Rob Peck ...ihnp4!hplabs!dana!rap --- cut here, might be Manx-compatible (cc +L ...; ln ... c32.lib, at least) #include "exec/types.h" #include "exec/exec.h" #include "exec/nodes.h" #include "exec/lists.h" #include "exec/memory.h" #include "exec/interrupts.h" #include "exec/ports.h" #include "exec/libraries.h" #include "exec/io.h" #include "exec/tasks.h" #include "exec/execbase.h" #include "devices/narrator.h" #include "libraries/translator.h" struct MsgPort *readPort=0; struct MsgPort *writePort=0; extern struct MsgPort *CreatePort(); extern struct IORequest *CreateExtIO(); struct narrator_rb *wn=0; struct mouth_rb *rn=0; struct Library *TranslatorBase =0; UBYTE *sampleInput; UBYTE outputString[500]; SHORT rtnCode, readError, writeError, error; UBYTE audChanMasks[4] = { 3,5,10,12 }; extern struct Library *OpenLibrary(); #define REVISION 1 char *words[ ] = { "da","zee","da","zee","give","me", "your","an","sir","doooo" }; long pitches[] = { 300, 285, 270, 250, 260, 270, 285, 270, 285, 230 }; main() { long i; TranslatorBase = OpenLibrary("translator.library",REVISION); if(TranslatorBase == NULL) exit(20); writePort = CreatePort(0,0); if(writePort == NULL) goto cleanup; readPort = CreatePort(0,0); if(readPort == NULL) goto cleanup; wn = (struct narrator_rb *)CreateExtIO(writePort, sizeof(struct narrator_rb)); rn = (struct mouth_rb *)CreateExtIO(readPort, sizeof(struct mouth_rb)); if(rn == NULL || wn == NULL) goto cleanup; wn->ch_masks = audChanMasks; wn->nm_masks = 1; /* restrict to one channel */ wn->message.io_Data = (APTR)outputString; wn->message.io_Length = strlen(outputString); wn->mouths = 0; /* NO MOUTHS! Wont read em anyhow.*/ wn->message.io_Command = CMD_WRITE; error = OpenDevice("narrator.device",0,wn,0); if(error != 0) goto cleanup; for(i=0; i<10; i++) { sampleinput = words[i]; rtnCode = Translate(sampleInput, strlen(sampleInput),outputString,500); wn->pitch = pitches[i]; wn->mode = 1; /* ROBOTIC */ wn->message.io_Data = (APTR)outputString; wn->message.io_Length = strlen(outputString); wn->message.io_Command = CMD_WRITE; writeError = DoIO(wn); } cleanup: if(wn->message.io_Device) CloseDevice(wn); if(wn) DeleteExtIO(wn); if(rn) DeleteExtIO(rn); if(TranslatorBase) CloseLibrary(TranslatorBase); if(readPort) DeletePort(readPort); if(writePort) DeletePort(writePort); }