I am student of BS IT and now making a voice based software for blind people so that they may use the system by giving voice commands to read/write files, emails and also listen songs through my software.
But I am currently stuck in my one activity that is to make media player controls as voice controls.
User say pause and media player would perform action on this command "pause" and similar for stop and play.
I used following code and add windows media player as its reference
Expand|Select|Wrap|Line Numbers
- Imports System.Speech.Recognition
- Public Class Form2
- Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- AxWindowsMediaPlayer1.URL = "songs playlist"
- Dim engine As New Speech.Recognition.SpeechRecognitionEngine
- Dim dictionGrammar As New Speech.Recognition.DictationGrammar
- Dim recognitionResult As Speech.Recognition.RecognitionResult
- Dim timeSpan As New TimeSpan(0, 0, 15)
- engine.SetInputToDefaultAudioDevice()
- engine.LoadGrammar(dictionGrammar)
- recognitionResult = engine.Recognize(timeSpan)
- For Each word As RecognizedWordUnit In recognitionResult.Words
- MessageBox.Show(word.Text)
- If word.Text = "play" Then
- AxWindowsMediaPlayer1.Ctlcontrols.play()
- ElseIf word.Text = "pause" Then
- 'Process.Start("pause")
- AxWindowsMediaPlayer1.Ctlcontrols.pause()
- ElseIf word.Text = "stop" Then
- ' Process.Start("stop")
- AxWindowsMediaPlayer1.Ctlcontrols.stop()
- End If
- Next
- End Sub
- End Class