Hi all.


I have an ASP.NET application that uses SAPI 5 to generate voice (based on
text).

It is all working very well, the voice is generated and send back to the
client (browser).



The application is using a TTS program (Text to speech) from Acepela, this
TTS is run as an service on the server (windows 2000).



The problem is that when I call the sound generator through the SAPI 5/Com
interface (Interop.SpeechLib), the TTS is started in a separate instance,
i.e. the com interface is not reusing the instance that is already running
on the server. This is causing some conflicts in the TTS (when other
application is using the TTS simultaneously).



I enclose the source code (without logging and error handling) that is used
to generate a wav file.



I have been struggling with this fore quiet some time - any help would be
appreciated.



Thanks

Georg



[SuppressUnmanagedCodeSecurityAttribute()]

public bool MakeVoiceFile(string FileName, string Text2Voice, string
VoiceName)

{



    SpVoice voice = GetVoice(VoiceName);

    if(voice == false)

        return false;



    SpFileStream SpFileStream = new SpFileStream();



    SpFileStream.Format.Type = SpeechAudioFormatType.SAFT11kHz8BitMono;



    SpFileStream.Open(FileName, SpeechStreamFileMode.SSFMCreateForWrite,
false);

    voice.AudioOutputStream = SpFileStream;



    voice.Speak(Text2Voice,

                SpeechVoiceSpeakFlags.SVSFlagsAsync |
SpeechVoiceSpeakFlags.SVSFIsXML);



    voice.WaitUntilDone(System.Threading.Timeout.Infinite);



    SpFileStream.Close();

    return true;



}



[SuppressUnmanagedCodeSecurityAttribute()]

private SpVoice GetVoice(string VoiceName)

{

    SpVoice voice = new SpVoice();



    int VoiceCount = voice.GetVoices("", "").Count;



    for (int i = 0; i < VoiceCount; i++)

    {



        SpObjectToken sp = voice.GetVoices("", "").Item(i);

        if (sp.GetDescription(1033).CompareTo(VoiceName) == 0)

        {

            voice.Voice = sp;

            return voice;

        }

    }



    return null;

}






===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to