hello guys..i'm yusoff hakimi..i have the problem with my voice activated coding..actually i want to add voice application on my media player but until now my code still wrong and actually the code doesn't contains error but the application is not running..this is my code..
Public Class Form1
Inherits System.Windows.Forms.Form
'command and control
Private WithEvents RC As SpeechLib.ISpRecoContext
Private myGrammar, b As SpeechLib.ISpeechRecoGrammar
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
'command and control
'***command and control***
Private Sub Form_Load()
RC = New SpeechLib.SpSharedRecoContextClass
myGrammar.RC.SpeechLib.IspRecoGrammer.CreateGrammar()
myGrammar.CmdLoadFromFile("sol.xml", SpeechLib.SpeechLoadOption.SLODynamic)
myGrammar.CmdSetRuleIdState(0, SpeechLib.SpeechRuleState.SGDSActive)
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
'************************************************************
If Label1.Text = "Exit" Then Application.Exit()
If Label1.Text = "Play" Then player.Ctlcontrols.play()
'***********************************************************
End Sub
Private Sub RC_StartStream(ByVal StreamNumber As Long, ByVal StreamPosition As Object)
Label2.Text = Val(StreamNumber)
End Sub
'***command and control***
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents player As AxWMPLib.AxWindowsMediaPlayer
Friend WithEvents opd As System.Windows.Forms.OpenFileDialog
Friend WithEvents MMenu As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents open As System.Windows.Forms.MenuItem
Friend WithEvents mexit As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
Friend WithEvents play As System.Windows.Forms.MenuItem
Friend WithEvents mstop As System.Windows.Forms.MenuItem
Friend WithEvents mpause As System.Windows.Forms.MenuItem
Friend WithEvents mvolume As System.Windows.Forms.MenuItem
Friend WithEvents mup As System.Windows.Forms.MenuItem
Friend WithEvents mdown As System.Windows.Forms.MenuItem
Friend WithEvents mmute As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.player = New AxWMPLib.AxWindowsMediaPlayer
Me.opd = New System.Windows.Forms.OpenFileDialog
Me.MMenu = New System.Windows.Forms.MainMenu(Me.components)
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.open = New System.Windows.Forms.MenuItem
Me.mexit = New System.Windows.Forms.MenuItem
Me.MenuItem5 = New System.Windows.Forms.MenuItem
Me.play = New System.Windows.Forms.MenuItem
Me.mstop = New System.Windows.Forms.MenuItem
Me.mpause = New System.Windows.Forms.MenuItem
Me.mvolume = New System.Windows.Forms.MenuItem
Me.mup = New System.Windows.Forms.MenuItem
Me.mdown = New System.Windows.Forms.MenuItem
Me.mmute = New System.Windows.Forms.MenuItem
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox1 = New System.Windows.Forms.TextBox
CType(Me.player, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'player
'
Me.player.Enabled = True
Me.player.Location = New System.Drawing.Point(0, 0)
Me.player.Name = "player"
Me.player.OcxState = CType(resources.GetObject("player.OcxState"
, System.Windows.Forms.AxHost.State)
Me.player.Size = New System.Drawing.Size(298, 250)
Me.player.TabIndex = 1
'
'MMenu
'
Me.MMenu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem5})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.open, Me.mexit})
Me.MenuItem1.Text = "File"
'
'open
'
Me.open.Index = 0
Me.open.Text = "Open"
'
'mexit
'
Me.mexit.Index = 1
Me.mexit.Text = "Exit"
'
'MenuItem5
'
Me.MenuItem5.Index = 1
Me.MenuItem5.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.play, Me.mstop, Me.mpause, Me.mvolume})
Me.MenuItem5.Text = "Player"
'
'play
'
Me.play.Index = 0
Me.play.Text = "Play"
'
'mstop
'
Me.mstop.Index = 1
Me.mstop.Text = "Stop"
'
'mpause
'
Me.mpause.Index = 2
Me.mpause.Text = "Pause"
'
'mvolume
'
Me.mvolume.Index = 3
Me.mvolume.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mup, Me.mdown, Me.mmute})
Me.mvolume.Text = "Volume "
'
'mup
'
Me.mup.Index = 0
Me.mup.Text = "Up"
'
'mdown
'
Me.mdown.Index = 1
Me.mdown.Text = "Down"
'
'mmute
'
Me.mmute.Index = 2
Me.mmute.Text = "Mute"
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(304, 9)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(39, 13)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Label1"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(304, 55)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(39, 13)
Me.Label2.TabIndex = 3
Me.Label2.Text = "Label2"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(313, 71)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(100, 20)
Me.TextBox2.TabIndex = 5
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(313, 25)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(100, 20)
Me.TextBox1.TabIndex = 4
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(427, 247)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.player)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Menu = Me.MMenu
Me.Name = "Form1"
Me.Text = "Media Player"
CType(Me.player, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles open.Click
Try
opd.InitialDirectory = "c:\"
opd.ShowDialog()
player.URL = opd.FileName
player.Ctlcontrols.play()
Catch ex As Exception
MessageBox.Show("Some error occur so can't play media", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub mexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mexit.Click
Application.Exit()
End Sub
Private Sub play_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles play.Click
player.Ctlcontrols.play()
End Sub
Private Sub mstop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mstop.Click
player.Ctlcontrols.stop()
End Sub
Private Sub mpause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mpause.Click
player.Ctlcontrols.pause()
End Sub
Private Sub mup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mup.Click
player.settings.volume = player.settings.volume + 10
End Sub
Private Sub mdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mdown.Click
player.settings.volume = player.settings.volume - 10
End Sub
Private Sub mmute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmute.Click
If player.settings.volume = player.settings.mute() Then
player.settings.volume = 20
Else
player.settings.volume = player.settings.mute()
End If
End Sub
Private Sub player_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles player.Enter
End Sub
End Class
/***********/
i'm using sapi engine and are this way is efficients?