0 Replies - 407 Views - Last Post: 17 November 2008 - 11:09 PM Rate Topic: -----

#1 harshalasith  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-November 08

How to solve my Speech recognize program

Post icon  Posted 17 November 2008 - 11:09 PM

Hi all

i was create Speech recognize sample project.i used SAPI 5.1 SDK and run it.it was compile and run normaly but when i speech for in put command and the program wasnt any responce.i was add Microsoft Speech Object Library before run my project.please tell me is my code if wrong or any suitable opinion for solve my problem.

thanks.

this is my code.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Option Explicit Off

Imports System
Imports System.IO
Imports System.Media
Imports System.Reflection
Imports System.Resources
Imports System.Runtime.InteropServices
Imports System.Windows.Forms.Application
Imports SpeechLib



Public Class Form1
   
	Public WithEvents RC As SpSharedRecoContext
	Public myGrammar As ISpeechRecoGrammar

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

		On Error GoTo EH

		RC = New SpSharedRecoContext

		myGrammar = RC.CreateGrammar
		myGrammar.CmdLoadFromFile("E:/SP new/sol.xml", SpeechLoadOption.SLODynamic)
		myGrammar.CmdSetRuleIdState(0, SpeechRuleState.SGDSActive)

EH:
		If Err.Number Then ShowErrMsg()
	End Sub

	Private Sub RC_FalseRecognition(ByVal StreamNumber As Long, ByVal StreamPosition As Object, ByVal Result As SpeechLib.ISpeechRecoResult)
		Label1.Text = "(no recognition)"
	End Sub

	Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
		Label1.Text = Result.PhraseInfo.GetText
	End Sub

	Private Sub RC_StartStream(ByVal StreamNumber As Long, ByVal StreamPosition As Object)
		Label2.Text = Val(StreamNumber)
	End Sub

	Private Sub ShowErrMsg()

		' Declare identifiers:
		Const NL = vbNewLine
		Dim T As String

		T = "Desc: " & Err.Description & NL
		T = T & "Err #: " & Err.Number
		MsgBox(T, vbExclamation, "Run-Time Error")
		End

	End Sub

End Class



-------------------------------------------------------------------------------------------------------------------------------------------------------------------

sol.xml



<GRAMMAR LANGID="409">
<DEFINE>
<ID NAME="RID_NewGame" VAL="101"/>
</DEFINE>

<RULE NAME="newgame" ID="RID_NewGame" TOPLEVEL="ACTIVE">
<P>new +game</P>
</RULE>
</GRAMMAR>


-------------------------------------------------------------------------------------------------------------------------------------------------------------------

Is This A Good Question/Topic? 0
  • +

Page 1 of 1