Article View: comp.sys.amiga.tech
Article #449narrator problem
From: Philip Hingston
Date: Tue, 11 Jul 1989 00:11
Date: Tue, 11 Jul 1989 00:11
78 lines
2701 bytes
2701 bytes
Can any gurus out there help with the following problem? I cobbled this
piece of code from bits and pieces here and there. Mostly it works fine
but it is not robust. Sometimes it crashes the machine, sometimes after
sending some phonemes to be spoken, they are repeated indefinitely, sometimes
no "shape" messages are recieved, sometimes the narrator decides not to
respond any more, sometimes the machine hangs up. As you can see, a few problems
arise! Any suggestions?
Thanks phi.
#define NRB struct narrator_rb
#define MRB struct mouth_rb
/* pointers to message ports and io request blocks */
static struct MsgPort *WPort = NULL;
static struct MsgPort *RPort = NULL;
static NRB *wmes = NULL;
static MRB *rmes = NULL;
/* preferences for allocation of audio channels */
static BYTE AudMask[] = {3, 5, 10, 12};
/* set up machinery for talking */
OpenTalk()
{
WPort = (struct MsgPort *)CreatePort(0, 0);
if(WPort == NULL) return FALSE;
RPort = (struct MsgPort *)CreatePort(0, 0);
if(RPort == NULL) return FALSE;
wmes = (NRB *)CreateExtIO(WPort, sizeof(NRB));
if(wmes == NULL) return FALSE;
rmes = (MRB *)CreateExtIO(WPort, sizeof(MRB));
if(rmes == NULL) return FALSE;
wmes->message.io_Command = CMD_WRITE;
if(OpenDevice("narrator.device", 0, wmes, 0)) return FALSE;
rmes->voice.message.io_Device = wmes->message.io_Device;
rmes->voice.message.io_Unit = wmes->message.io_Unit;
rmes->voice.message.io_Command = CMD_READ;
return TRUE;
}
/* say something */
void SayIt(phonemes, volume, rate, pitch, sex, freq, mode)
char *phonemes;
short volume, rate, pitch, sex, freq, mode;
{
wmes->ch_masks = AudMask;
wmes->nm_masks = sizeof(AudMask);
wmes->mouths = 1;
wmes->volume = volume;
wmes->rate = rate;
wmes->pitch = pitch;
wmes->sex = sex;
wmes->sampfreq = freq;
wmes->mode = mode;
wmes->message.io_Data = (APTR)phonemes;
wmes->message.io_Length = strlen(phonemes);
/* Here's the crunch */
SendIO(wmes);
rmes->voice.message.io_Error = 0;
DoIO(rmes);
while(rmes->voice.message.io_Error != ND_NoWrite) {
SetMouth(rmes->width, rmes->height, rmes->shape);
DoIO(rmes);
}
SetMouth(5, 0, 0);
GetMsg(WPort);
}
Technical Details
Message-ID:
<2210@goanna.oz>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!murtoa.cs.mu.oz.au!goanna!phiShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!murtoa.cs.mu.oz.au!goanna!phi From: phi@goanna.oz (Philip Hingston) Newsgroups: comp.sys.amiga.tech Subject: narrator problem Message-ID: <2210@goanna.oz> Date: 11 Jul 89 00:11:37 GMT Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 78