I am following an old C manual example (Inside the Amiga with C by Thomas Berry published by SAMS) that is dated back to the Lattice days), and Workbench 1.3 in regards to creating a program that makes the Amiga speak using the narrator.device and Translate().
My system is A500, running 3.1 Roms, and I am getting no errors during compile with SASC/C++ 6.xx. I get no crashes when I run the program, and the device seems to open correctly, and the Translate() is returning a converted string to Phonetics OK.
The system is not making any sound however. I was wondering if 2.04 to 3.xx roms handle the speech routines differently than the old 1.3 Roms that I should be aware of?
Is there a modern source example available I could look at to compare with my old example?
/***************************************************/
#include "stdafx.h"
#include "main_protos.h"
struct Library *TranslatorBase=NULL;
extern struct Library *OpenLibrary();
struct MsgPort *WPort, *RPort;
extern struct IORequest *CreateExtIO();
extern struct Library *OpenLibrary();
struct narrator_rb *wmes;
struct mouth_rb *rmes;
BYTE audChanMasks[]={3,5,10,12};
int main(void)
{
UBYTE in_string[80], out_string[300];
printf("Enter a string ");
gets(in_string);
if(get_phoneme(in_string, strlen(in_string),out_string, 300) == ERR)
{
puts("get_phoneme error!");
exit(FALSE);
}
printf("The phoneme translation of %s is %s\n", in_string, out_string);
if(talk_to_me(out_string) == ERR)
exit(FALSE);
return 0;
}
/***************************************************************/
int get_phoneme(in,inLen,out,outLen)
UBYTE *in,*out;
SHORT inLen,outLen;
{
int error=0;
TranslatorBase = (struct Library*)OpenLibrary("translator.library",1);
if(TranslatorBase==NULL)
{
puts("Cannot Open Translator.library!");
return ERR;
}
// Translate this string to phonetics
if(error=Translate(in,inLen,out,outLen) != 0)
{
printf("Cannot Translate %d\n",error);
return ERR;
}
CloseLibrary(TranslatorBase);
return SUCCESS;
}
/***************************************************************/
talk_to_me(speech)
UBYTE *speech;
{
if((WPort=(struct MsgPort*)CreatePort(0,0)) == NULL)
return (ERR);
if((RPort=(struct MsgPort*)CreatePort(0,0)) == NULL)
return (ERR);
if((wmes=(struct narrator_rb*)CreateExtIO(WPort,sizeof(struct
narrator_rb))) == NULL)
return (ERR);
if((rmes=(struct mouth_rb*)CreateExtIO(RPort,sizeof(struct mouth_rb)))
== NULL)
return (ERR);
wmes->message.io_Command = CMD_WRITE;
wmes->message.io_Data = (APTR)speech;
wmes->message.io_Length = strlen(speech);
wmes->ch_masks = audChanMasks;
wmes->nm_masks = sizeof(audChanMasks);
if(OpenDevice("narrator.device", 0, wmes, 0) != 0)
return (ERR);
wmes->mouths = 0;
wmes->volume = 64;
wmes->rate = 20;
wmes->sex = MALE;
wmes->pitch = DEFPITCH;
rmes->voice.message.io_Device = wmes->message.io_Device;
rmes->voice.io_Unit = wmes->message.io_Unit;
rmes->width = 0;
rmes->height = 0;
rmes->voice.message.io_Command = CMD_READ;
rmes->voice.io_Error = 0;
SendIO(wmes);
while(rmes->voice.message.io_Error != ND_NoWrite)
DoIO(rmes);
return(SUCCESS);
}