Speech recognizer for MDI application

SureshDeoda

New member
Joined
Oct 5, 2009
Messages
4
Programming Experience
1-3
Hi all,
New here and just started working on .NET...:)
I was making a MDI app with vb.NET and SAPI
i used System.speech.recognition namespace
and SpeechRecognizer element..
working for single doc.. bt when i go for new form with same giving

An error occurred creating the form. See Exception.InnerException for details. The error is: Unable to cast COM object of type 'System.Speech.Internal.SapiInterop.SpSharedRecognizer' to interface type 'System.Speech.Internal.SapiInterop.ISpRecognizer'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C2B5F241-DAA0-4507-9E16-5A1EAA2B7A5C}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

this error...
i would be glad if anyone can guide me with that...
the code i wrote is like this




Dim recognizer As SpeechRecognizer


Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

Me.recognizer = New SpeechRecognizer
Me.speechEnable()

End Sub

Private Sub speechEnable()

Dim myGram As Grammar
myGram = New Grammar("D:\data\logTest.xml")

myGram.Enabled = True
recognizer.UnloadAllGrammars()
recognizer.LoadGrammar(myGram)

'attach the event handler
AddHandler recognizer.SpeechRecognized, AddressOf recognizer_SpeechRecognized
AddHandler recognizer.SpeechDetected, AddressOf recognizer_SpeechDetected

End Sub
 
I tried using SpeechLib namespace also...

Dim WithEvents RC As SpSharedRecoContext
Dim Recognizer As SpSharedRecognizer
Dim myGrammar As ISpeechRecoGrammar

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

' If (RC Is Nothing) Then
RC = New SpSharedRecoContext
Recognizer = RC.Recognizer
myGrammar = RC.CreateGrammar
'Try
myGrammar.CmdLoadFromFile("C:\Documents and Settings\My Documents\sol1.xml", SpeechLoadOption.SLODynamic)
myGrammar.CmdSetRuleIdState(5, SpeechRuleState.SGDSActive)
End Sub
Private Sub RC_Recognition(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult) Handles RC.Recognition

Me.TextBox1.Text = Result.PhraseInfo.GetText
End Sub

it did work with XP( on which i am writing codes) bt when i ported it on the vista
it didnt worked..
So i guess u can help me with this..:)
 
Back
Top