/*************************************************************************/ /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */ /*************************************************************************/ /* */ /* speak */ /* */ /* Speaks the defined text using the narrator device which can be found */ /* on OS2. In order for the program to be compatible with OS3, the OS2 */ /* files must be copied to the current workbench and the narrator */ /* device added. */ /* */ /* Compile using SASC: sc link speak.c */ /* */ /*************************************************************************/ #include #include #include #include #include #include #include #include #include #define TEXT "Good day from Wizardry and Steamworks!" int main(void) { struct MsgPort *VoiceMP; struct narrator_rb *VoiceIO; BYTE audio_chan[4] = { 3, 5, 10, 12 }; UBYTE PhonBuffer[500]; /* place to put the translation */ LONG rtnCode; /* return code from translation function */ /* Create message port. */ if (!(VoiceMP = CreateMsgPort())) { printf("Error: Could not create message port.\n"); return 1; } /* Create I/O request. */ if (!(VoiceIO = CreateIORequest(VoiceMP, sizeof(struct narrator_rb)))) { printf("error: could not create I/O request.\n"); return 1; } /* Open narrator device (from WB <= 2.0). */ if (OpenDevice("narrator.device", 0, (struct IORequest*)VoiceIO, 0L)) { printf("error: could not open narrator.device.\n"); return 1; } /* Translate text to phonemes. */ rtnCode = Translate(TEXT, strlen(TEXT), (APTR)&PhonBuffer[0], 500); VoiceIO->ch_masks = &audio_chan[0]; VoiceIO->nm_masks = sizeof(audio_chan); VoiceIO->message.io_Command = CMD_WRITE; VoiceIO->message.io_Offset = 0; VoiceIO->message.io_Data = PhonBuffer; VoiceIO->message.io_Length = strlen(PhonBuffer); DoIO((struct IORequest*)VoiceIO); /* Close the narrator device */ CloseDevice((struct IORequest*)VoiceIO); return 0; }