LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Text to Speech via SAPI - Output to File

Group,

 

I have been using the Speech API (SAPI) to do TTS (text to speech) to the local output (speaker).  However I would like to output to a WAV file instead.  My working knowledge of the SAPI is pretty low, so any help would be appreciated.  Here is the code I use now.  It works just fine, but only outputs to the speaker.  In the SAPI documentation, their example uses SPBindToFile, which returns an output stream, then calls SetOutput() to output to this stream, and then calls Speak (or in my case Speech_ISpeechVoiceSpeak) to send the text to the output as voice. I just don't know how to implement this in CVI.  I have done the conversion on the SAPI -> Create the ActiveX Automation Server, and have speech.fp loaded in the project.

 

Thanks in advance, David

 

 

Window XP Pro, CVI 5.0.1

 

/*--------------------------------------------------------------------------------------------------*/

void SpeakTextPhrase(char *text)
{
/* The following code converts text to speech using SAPI and speaks the phrase using the default voice.  The
    default voice can be set in Control Panel:Speech.  */
   

CAObjHandle  voice = 0;
long streamNumber;

    vstat = Speech_NewISpeechVoice (NULL, &voice);
   
    SetWaitCursor (1);
    if (vstat >= 0) Speech_ISpeechVoiceSpeak(voice, NULL, text, SpeechConst_SVSFDefault, &streamNumber);
    else
    {
        CA_GetAutomationErrorString(vstat,errormsg,512);
        printf("%s\n",errormsg);
    }
    CA_DiscardObjHandle(voice);
    SetWaitCursor (0);
}

David Eaton
0 Kudos
Message 1 of 4
(3,519 Views)

Hello David,

 

Did you create an ActiveX Controller or Server? I only ask because creating a controller will load all the functionality for you using the type library.

 

Now, National Instruments doesn't really provide documentation on how to use the particular functions that are in this library because the functions within are largely dictated by the creator of the server and its type library, which in this case is Microsoft. So you should probably get to know the documentation for the Speech SDK (available at the same link where you got the SDK) to see how to interact with it appropriately.

 

From some prelimary digging it looks like "ISpeechWaveFormateEx" or possibly "ISpStreamFormatConverter" might be the functions you need.

With warm regards,

David D.
0 Kudos
Message 2 of 4
(3,494 Views)

David,

 

I created the Server.  I will go back and look at creating the Controller.  Maybe this will help.

 

Thanks, David

 

David Eaton
0 Kudos
Message 3 of 4
(3,480 Views)

David,

 

I recreated the Speech Automation controller.  Again, as before, what is listed in the SAPI documentation, and the functions created by CVI are not even close.  The functions for BindToFile and SetOutput don't exist.  I have spent all the time on this I can.  I will use Visual Studio to build the voice application, as I can access the SAPI as a COM object, and I have a number of examples for that.

 

This project has been a thorn in my side from day ONE, and I will be glad to get it finished.

 

David

 

 

David Eaton
0 Kudos
Message 4 of 4
(3,478 Views)