By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,335 Members | 2,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,335 IT Pros & Developers. It's quick & easy.

voice based commands for media player

P: 1
Hi,
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
  1. Imports System.Speech.Recognition
  2.  
  3. Public Class Form2
  4.  
  5.     Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6. AxWindowsMediaPlayer1.URL = "songs playlist"       
  7.  Dim engine As New Speech.Recognition.SpeechRecognitionEngine
  8.  
  9.         Dim dictionGrammar As New Speech.Recognition.DictationGrammar
  10.  
  11.         Dim recognitionResult As Speech.Recognition.RecognitionResult
  12.  
  13.         Dim timeSpan As New TimeSpan(0, 0, 15)
  14.  
  15.         engine.SetInputToDefaultAudioDevice()
  16.  
  17.         engine.LoadGrammar(dictionGrammar)
  18.  
  19.         recognitionResult = engine.Recognize(timeSpan)
  20.  
  21.         For Each word As RecognizedWordUnit In recognitionResult.Words
  22.  
  23.  
  24.  
  25.             MessageBox.Show(word.Text)
  26.             If word.Text = "play" Then
  27.                 AxWindowsMediaPlayer1.Ctlcontrols.play()
  28.             ElseIf word.Text = "pause" Then
  29.                 'Process.Start("pause")
  30.                 AxWindowsMediaPlayer1.Ctlcontrols.pause()
  31.             ElseIf word.Text = "stop" Then
  32.                 ' Process.Start("stop")
  33.                 AxWindowsMediaPlayer1.Ctlcontrols.stop()
  34.                         End If
  35.         Next
  36.  
  37.     End Sub
  38. End Class
Please help me in my task
Dec 2 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.