C# .NET - SpeechLib COM component doesnt work

Asked By Ravi on 27-Aug-11 05:54 AM
Hello,

I have used Microsoft SpeechLibrary 5.1 a COM dll to perform text to speech action in one of my web application. I have made reference of this dll file to my ASP.Net project and added the code like the following:

using SpeechLib;
protected void btnSubmit_Click(object sender, EventArgs e)
        {
SpVoice voice = new SpVoice();

                char[] text = { 's', 'p', 'e', 'a','k' };
                for (int i = 0; i < text.Length; i++)
                {
                    voice.Speak(text[i].ToString(), SpeechVoiceSpeakFlags.SVSFDefault);
                }
}

But when I debug the code, I am getting the following exception

Attempted to access an unloaded appdomain. (Exception from HRESULT: 0x80131014)
   at System.StubHelpers.StubHelpers.InternalGetCOMHRExceptionObject(Int32 hr, IntPtr pCPCMD, Object pThis)
   at System.StubHelpers.StubHelpers.GetCOMHRExceptionObject(Int32 hr, IntPtr pCPCMD, Object pThis)
   at SpeechLib.ISpeechVoice.Speak(String Text, SpeechVoiceSpeakFlags Flags)
   at Test.btnSubmit_Click(Object sender, EventArgs e) in 

And also getting one more exception sometimes

{System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at SpeechLib.ISpeechVoice.Speak(String Text, SpeechVoiceSpeakFlags Flags)
   at Test.btnSubmit_Click(Object sender, EventArgs e) in 


I am using IIS7 webserver and the Website Properties are:
Application Pool: ASP.NET v4.0
Pipeline mode: Integrated
Reena Jain replied to Ravi on 27-Aug-11 06:08 AM
HI,

Based on my experience such exception as "AppDomainUnloadedException" is likely caused by the aspnet application AppDomain is recycled.

After the web.config change all web service requests failed. The solution was to reset the IIS

for more help check this
http://msdn.microsoft.com/en-us/library/system.appdomainunloadedexception.aspx
Anoop S replied to Ravi on 27-Aug-11 07:22 AM
did you missed any component to install in the production server?
or did you missed any assembly dll to upload on production server?
Ravi replied to Ravi on 27-Aug-11 07:37 AM
No. I havent uploaded it to any deployment server. I am checking this in my local system only. What other components need to be installed other than this dll to make use of this Speechlib class properly.
Devil Scorpio replied to Ravi on 27-Aug-11 07:29 PM
Hi Ravi,

You can create an object of SAPI.SpVoice that is native speech voice of Microsoft Windows OS

Here is the code for speech
CreateObject("SAPI.SpVoice").Speak"Eggheadcafe"