Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I developed a speech recognition program using SpSharedRecoContext.
The program works but is too slow. I thought I would change the program to use
SpInProcRecoContext which should provide better performance and quality. I expected
the change to be easy with some necessary tweeks.
However, I have encountered a problem that I can not understand.
I can demonstrate the problem with the following:
Imports SpeechLib
Dim WithEvents RC As SpInProcRecoContext
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
RC = New SpInProcRecoContext '---- This line causes the following runtime exception:
End Sub
End Class

System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2147201021
Message=Creating an instance of the COM component with CLSID {73AD6842-ACE0-45E8-A4DD-8795881A2C2A} from the IClassFactory failed due to the following error: 80045003.
Source=WindowsApplication25
StackTrace:
at WindowsApplication25.Form1.Form1_Load(Object sender, EventArgs e) in c:\users\chuck\documents\visual studio 2010\Projects\WindowsApplication25\WindowsApplication25\Form1.vb:line 7
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:

80045003 error is un SPERR_UNSUPPORTED_FORMAT ;"The caller has specified an unsupported format. "

If I change it to the following using SpSharedRecoContext, I get no runtime errors, and was the bases for
my Speech Recognition programs that is working.
Imports SpeechLib
Dim WithEvents RC As  SpSharedRecoContext
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
RC = New  SpSharedRecoContext
End Sub
End Class

I have researched and have found that others have had similar problems
with SpInProcRecoContext, but I found no solutions.
I am running Windows 8 on the development system with Visual Studio 2010. Based on information,
I read on line, I removed and reinstalled Visual Studio 2010 and SDK . I took the
runtime and tried it on a Windows 7 system, with the same results. I download the trial
Visual Studio 2012 and got the same error. I have seen very similar code
on the Microsoft web site, so I don't think the issue is with the code.

However, the Microsoft example Set RC = New SpInProcRecoContext Set is used. When I include Set, VB
removes the Set from the code. I am not sure what that is about.

Can anyone provide me some insight on this problem? Thanks
Posted
Updated 19-Feb-13 7:45am
v2

1 solution

Why using SpeechLib, if you can use System.Speech.Recognition,
http://msdn.microsoft.com/en-us/library/system.speech.recognition.aspx[^]?

Use either System.Speech.Recognition.SpeechRecognizer or System.Speech.Recognition.SpeechRecognitionEngine, see the code samples. I worked with both, they work. You will find code sample on the MSDN help pages for these classes:
http://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognizer.aspx[^],
http://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognitionengine.aspx[^].

They have slightly different features and are designed for STA and MTA thread apartment states, so if your application uses different apartment state (for example, WPF only works with STA), you will need to use a separate thread for recognition. They are using the same engine, anyway.

The assembly "System.Speech.dll" is installed in GAC, so you reference it through the tab ".NET" of the VS "Add reference" window.

Good luck,
—SA
 
Share this answer
 

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