Welcome, Guest. Please login or register.

Author Topic: Artificial Speech "narrator.device" and SASC/C++  (Read 3770 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline jjansTopic starter

  • Full Member
  • ***
  • Join Date: Aug 2003
  • Posts: 241
    • Show all replies
Artificial Speech "narrator.device" and SASC/C++
« on: September 26, 2004, 07:49:54 PM »
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);      
}
\\"Most Xenonites fly imports. Unfortunately yours is a domestic model. Don\\\'t be surprised if the gears work in reverse\\" - Volhaul\\\'s Revenge: Close Encounters of the Sludge Kind.

GVP A530, VXL 30/32, Supra 500XP, A590, A1000.
 

Offline jjansTopic starter

  • Full Member
  • ***
  • Join Date: Aug 2003
  • Posts: 241
    • Show all replies
Re: Artificial Speech "narrator.device" and SASC/C++
« Reply #1 on: October 07, 2004, 12:11:31 AM »
Thanks for the example!

Initial compile still gives me no speech, but I have to take some time  to study your code to figure out why.

Your Health! :pint:  :pint:  :pint:  :pint:
\\"Most Xenonites fly imports. Unfortunately yours is a domestic model. Don\\\'t be surprised if the gears work in reverse\\" - Volhaul\\\'s Revenge: Close Encounters of the Sludge Kind.

GVP A530, VXL 30/32, Supra 500XP, A590, A1000.
 

Offline jjansTopic starter

  • Full Member
  • ***
  • Join Date: Aug 2003
  • Posts: 241
    • Show all replies
Re: Artificial Speech "narrator.device" and SASC/C++
« Reply #2 on: October 07, 2004, 03:57:43 PM »
Well the AmigaDos 'Say' Command is working on all the machines I tested this on. I tried it on my client machine (also OS 3.1), rebooted to OS 1.3 (via SKICK), and even on WINUAE under different OS configs. Really got me stumped now.

I have a feeling I am missing something really simple here. It may be easier to simply call the exec cli command say (which is working) for my purposes, but then this may be more intense on resources will it not?

I have a feeling that time spent with Visual Studio C++ has spoiled me, and I have to re-read some more basics from the old manuals!:-o

Thanks for your input guys. I'll get it yet!!!!
Gotta go to work now    
\\"Most Xenonites fly imports. Unfortunately yours is a domestic model. Don\\\'t be surprised if the gears work in reverse\\" - Volhaul\\\'s Revenge: Close Encounters of the Sludge Kind.

GVP A530, VXL 30/32, Supra 500XP, A590, A1000.