Creating an instance of the COM component with CLSID
{B5E61148-76CA-4D31-9A1B-B3E893F7FBE8} from the IClassFactory failed due to
the following error: 800a0153.
My Code
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports SpeechEngine
Imports SpeechLib
Imports TestSpeechEngine
Friend Class Form1
Inherits System.Windows.Forms.Form
Dim SpeechCom As EngineSpeech
Dim IDCounter As Integer
Private Declare Function GetModuleFileName Lib "KERNEL32" Alias
"GetModuleFileNameA"(ByVal hModule As Integer, ByVal lpFileName As String,
ByVal nSize As Integer) As Integer
Public Function DebugMode() As Boolean
Dim strFileName As String
Dim lngCount As Integer
strFileName = New String(Chr(0), 255)
lngCount = GetModuleFileName(VB6.GetHInstance.ToInt32, strFileName, 255)
strFileName = VB.Left(strFileName, lngCount)
If UCase(VB.Right(strFileName, 7)) <> "VB6.EXE" Then
DebugMode = False
Else
DebugMode = True
End If
End Function
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles Command1.Click
Command1.Enabled = False
Command2.Enabled = True
IDCounter = IDCounter + 1
SpeechCom.StartRawRecord()
End Sub
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles Command2.Click
Command1.Enabled = True
Command2.Enabled = False
SpeechCom.StopRawRecord(CStr(IDCounter & ".raw"))
If SpeechCom.TrainCommand(Text1.Text, IDCounter) Then
List1.Items.Add(Text1.Text)
End If
End Sub
Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles Command3.Click
Command4.Enabled = True
Command3.Enabled = False
SpeechCom.StopRawRecord(CStr(IDCounter & ".raw"))
System.Windows.Forms.Application.DoEvents()
Dim n As Integer
Dim no As Integer
n = SpeechCom.RecognizedCommands(IDCounter)
SpeechCom.ResetAlternativeList()
For no = 1 To n
List2.Items.Add(SpeechCom.GetNextAlternativeString & " " &
SpeechCom.GetNextAlternativeScore)
Next no
End Sub
Private Sub Command4_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles Command4.Click
List2.Items.Clear()
Command4.Enabled = False
Command3.Enabled = True
SpeechCom.StartRawRecord()
End Sub
Private Sub Command5_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles Command5.Click
If SpeechCom.SaveCommands(IDCounter) Then
MsgBox("Saved New Commands")
End If
End Sub
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles MyBase.Load
If DebugMode = True Then
MsgBox("Debug Mode Execution ? For faster execution kindly create an
executable and place it in the SpeechRecognitionEngine folder [probably
available in Program Files] ")
End
End If
SpeechCom = New SpeechEngine.EngineSpeech
SpeechCom.LoadCommands()
IDCounter = SpeechCom.IDCount
Dim no As Integer
For no = 1 To SpeechCom.CommandsTotal - 1
List1.Items.Add(SpeechCom.GetNextCommand)
Next no
End Sub
Private Sub Form1_FormClosed(ByVal eventSender As System.Object, ByVal
eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
'UPGRADE_NOTE: Object SpeechCom may not be destroyed until it is garbage
collected. Click for more:
'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
SpeechCom = Nothing
End Sub
End Class