David,
The following code can be used as a template for your requirement
Jan Dahle
#include <windows.h>
#include <sapi.h>
void SpeakAlarmMessage(char *msg, int msgLen, int volume)
{
//Speak the given text
static ISpVoice *pVoice = NULL;
GUID CLSID_SpVoice = {0x96749377, 0x3391, 0x11D2, 0x9E, 0xE3, 0x0, 0xC0,
0x4F, 0x79, 0x73, 0x96};
GUID IID_ISpVoice = {0x6C44DF74, 0x72B9, 0x4992, 0xA1, 0xEC, 0xEF, 0x99,
0x6E, 0x04, 0x22, 0xD4};
WCHAR *wText;
char headerTxt[]= "<emph> GENERAL ALARM!. GENERAL ALARM!. <rate
speed='2'><pitch absmiddle='-3'><silence msec='1000'/>";
char tailTxt[]= "!<silence msec='1000'/> General ALARM!";
int i,j=0;
// Speech is using COM technology.Only continue if COM is successfully
initialized
if (SUCCEEDED(CoInitialize(NULL)))
{
// Create a speech instance
// if(SUCCEEDED(CoCreateInstance(&CLSID_SpVoice, NULL, CLSCTX_ALL,
&IID_ISpVoice, (VOID**)&pVoice)))
//if(SUCCEEDED(CoCreateInstance(&CLSID_SpVoice, NULL,
CLSCTX_INPROC_SERVER, &IID_ISpVoice, (VOID**)&pVoice)))
if ( pVoice ==NULL)
CoCreateInstance(&CLSID_SpVoice, NULL, CLSCTX_INPROC_SERVER,
&IID_ISpVoice, (VOID**)&pVoice);
if ( pVoice !=NULL)
{
// CVI 5.5 does not support WCHAR. Do it manually. Get some memory and
copy the text into it
if(wText = calloc (sizeof(headerTxt)+msgLen+sizeof(tailTxt),
sizeof(WCHAR)))
{
for (i=0; i< sizeof(headerTxt)-1;i++, j++) wText[j] = headerTxt[i];
for (i=0; i< msgLen ;i++, j++) wText[j] = msg[i];
//for (i=0; i< sizeof(tailTxt)-1 ;i++, j++) wText[j] = tailTxt[i];
wText[j] ='\0';
// Set the volume and speak
pVoice->lpVtbl->SetVolume (pVoice, (USHORT) volume);
pVoice->lpVtbl->Speak(pVoice, wText , SPF_IS_XML | SPF_ASYNC , NULL);
free(wText);
}
//Release the speech resource.
pVoice->lpVtbl->Release(pVoice);
}
// Release used COM resources.
CoUninitialize(); // #NOTE
}
}
"FoodScience" <x@no.email> wrote in message
news:1179864617182-524925@exchange.ni.com...
>I am creating a voice alarming system. I have the tools and hardware
>to place phone calls to chosen users, and deliver a voice message.
>The msg format is typically .WAV files. All of this system is up and
>running and doing beautifully.However, I would like to create custom
>messages, which requires a text -> speech processor to create the
>necessary WAV file (from text) to deliver via phone.I have used the ActiveX
>Automation Server (Tools:Create ActiveX Automation Server) to create a
>function panel from the Microsoft SAPI engine. However, I am stumped
>at this point. No idea where to start. All in want is a simple
>text-speech-file routine. All the other tools are up and running.Any
>examples, help, tips, etc would be appreciated. I am up against a
>deadline of June 23rd to demo for a group.Thanks in advance, David Eaton