Click here to Skip to main content
15,905,414 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a text-to-speech application and I want to be able to support SAPI version 4 as well as SAPI5.

I am using .NET 2.0 compatible, use COM interop (via the auto-generated SpeechLib.dll).
With this I am able to get only SAPI5 version voices, How to get SAPI4 version voices.

What would I need to use/do to make use of SAPI4 as well?

Thanks in advance for any help!
Posted

1 solution

Just determine the version that's installed, and put checks in your code to determine whether or not certain functions should be used.

C#
public interface ISapiFunctions
{
    public void Function1();
    public void Function2();
}

public class SapiBase : ISapiFunctions
{
    public virtual void Function1()
    {
        // do nothing
    }

    public virtual void Function2()
    {
        // do nothing
    }
}

public class Sapi4 : SapiBase
{
    public override void Function1()
    {
        // do something 
    }
}

public void Sapi5 : SapiBase
{
    public override void Function1()
    {
        // do something
    }

    public override void Function2()
    {
        // do something
    }
}


In the code above, if you instantiated the sapi4 class (because sapi v4 is currently what's installed), it would support the functionality in Function1, but NOT the functionality in Function2 (resulting in the base class' do-nothing copy to be executed). If you instantiate sapi5, all functionality would be available because sapi5 can perform the desired task. The end result would be that you could call Function1 AND Function2 from the code that instantiates either of the classes without worrying if the currently installed sapi version even supports it.
 
Share this answer
 
v3
Comments
Member 3827009 13-Sep-11 9:05am    
Thank you for the reply.

But as I asked I need How to get the SAPI4 voice list in C# application. When I am using the SpeechLib dll there is one method to get all the VoiceList was

SpeechLib.SpVoice x = new SpeechLib.SpVoice();
SpeechLib.ISpeechObjectTokens arrVoices = x.GetVoices();
But with this I can able to get only SAPI5 voice list not the SAPI4 voice.

I need method how to get the SAPI4 voices.
#realJSOP 13-Sep-11 9:30am    
That's probably because not all voices support both versions, and I would bet that most voice installers would only install the voices compatible with the version of speechlib.dll that you have.
Member 3827009 13-Sep-11 9:37am    
I have checked in net and found one software "Balabolka"
http://www.cross-plus-a.com/balabolka.htm
In this application they are supporting both SAPI4 and SAPI5 voices.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900