469,943 Members | 2,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,943 developers. It's quick & easy.

Voice recognition

Hi I have created a voice regnocnition program but I can't get it to work. The problem comes when my program comes to the command: VoiceCmd.Initialized = 1. It says access denied exception from HRESULT: 0x80030005 (STG_E_ACCESSDENIED.
Expand|Select|Wrap|Line Numbers
  1. Option Strict Off
  2. Option Explicit On
  3. Friend Class Frm_Voice_Command
  4.     Inherits System.Windows.Forms.Form
  5.     Private My_menu As Integer
  6.     Private Loop_1 As Integer
  7.     Private TCount As Integer
  8.  
  9.     Private Sub Cmd_Exit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cmd_Exit.Click
  10.         ' Code to 'EXIT' the application
  11.         Me.Close()
  12.     End Sub
  13.  
  14.     Private Sub Cmd_Open_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cmd_Open.Click
  15.         ' Code to 'OPEN' a database
  16.         CD1Open.ShowDialog()
  17.         CD1Save.FileName = CD1Open.FileName
  18.         ' I've only opened the Common dialog 'ShowOpen' form but you add
  19.         ' the rest of the 'Open' code here
  20.     End Sub
  21.  
  22.     Private Sub Cmd_Save_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cmd_Save.Click
  23.         ' Code to 'SAVE' a database
  24.         CD1Save.ShowDialog()
  25.         CD1Open.FileName = CD1Save.FileName
  26.         ' I've only opened the Common dialog 'ShowSave' form but you add
  27.         ' the rest of the 'Save' code here
  28.     End Sub
  29.  
  30.     Private Sub Cmd_Start_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cmd_Start.Click
  31.         If Cmd_Start.Text = "Listen" Then
  32.             ' Activate my list of commands. These will show in the 'What can I say' form of
  33.             ' Microsoft Voice apllication
  34.             VoiceCmd.Activate(My_menu)
  35.             Cmd_Start.Text = "Stop Listening" 'Change the command text
  36.             Lst_Commands.Enabled = True 'enable the List of commands (Visual)
  37.         Else
  38.             ' Deactivate my list of commands. These will now not show in the
  39.             ' 'What can I say' form of Microsoft Voice apllication
  40.             VoiceCmd.Deactivate(My_menu)
  41.             Cmd_Start.Text = "Listen" 'Change the command text
  42.             Lst_Commands.Enabled = False 'disable the List of commands (Visual)
  43.         End If
  44.     End Sub
  45.  
  46.     Private Sub Frm_Voice_Command_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
  47.         ' Dim some variables used for retriving commands from 'VoiceCmd'
  48.         'UPGRADE_NOTE: Command was upgraded to Command_Renamed. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
  49.         Dim Category, Command_Renamed, Description, Action As String
  50.         Dim Flags As Integer
  51.  
  52.         ' Initialize the voice control...
  53.         VoiceCmd.Initialized = 1
  54.         ' Create and return a Menu control
  55.         My_menu = VoiceCmd.get_MenuCreate("My Commands", "commands State", 4)
  56.         ' Enable our voice control
  57.         'UPGRADE_NOTE: Enabled was upgraded to CtlEnabled. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
  58.         VoiceCmd.CtlEnabled = 1
  59.         ' Suppress any voice errors that may occur
  60.         'VoiceCmd.SuppressExceptions = 1
  61.         ' Load our list of commands into the menu.
  62.         VoiceCmd.AddCommand(My_menu, 1, "white", "white colour", "listen list", 0, "")
  63.         VoiceCmd.AddCommand(My_menu, 1, "red", "red colour", "listen list", 0, "")
  64.         VoiceCmd.AddCommand(My_menu, 1, "green", "green colour", "listen list", 0, "")
  65.         VoiceCmd.AddCommand(My_menu, 1, "blue", "blue colour", "listen list", 0, "")
  66.         VoiceCmd.AddCommand(My_menu, 1, "open", "Open Database", "listen list", 0, "")
  67.         VoiceCmd.AddCommand(My_menu, 1, "save", "Save Database", "listen list", 0, "")
  68.         VoiceCmd.AddCommand(My_menu, 1, "exit", "Exit App", "listen list", 0, "")
  69.         VoiceCmd.AddCommand(My_menu, 1, "stop listening", "Stop Listen", "listen list", 0, "")
  70.         ' Activate the List of commands
  71.         VoiceCmd.Activate(My_menu)
  72.         Cmd_Start.Text = "Stop Listening"
  73.         Lst_Commands.Items.Clear()
  74.         'load the commands from the menu in to the list
  75.         TCount = VoiceCmd.get_CountCommands(My_menu)
  76.         For Loop_1 = 1 To TCount
  77.             VoiceCmd.GetCommand(My_menu, Loop_1, Command_Renamed, Description, Category, Flags, Action)
  78.             Lst_Commands.Items.Add(Command_Renamed)
  79.         Next Loop_1
  80.     End Sub
  81.  
  82.     Private Sub Frm_Voice_Command_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
  83.         ' Remove the commands from the menu
  84.         TCount = VoiceCmd.get_CountCommands(My_menu)
  85.         For Loop_1 = TCount To 1 Step -1
  86.             VoiceCmd.Remove(My_menu, Loop_1)
  87.         Next Loop_1
  88.         ' release the usage of the command menu.
  89.         VoiceCmd.ReleaseMenu(My_menu)
  90.         'UPGRADE_NOTE: Enabled was upgraded to CtlEnabled. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
  91.         VoiceCmd.CtlEnabled = 0
  92.     End Sub
  93.  
  94.     Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
  95.         ' After a perion of silence reset the last word heard
  96.         Detect.Text = "<Nothing>"
  97.     End Sub
  98.  
  99.     Private Sub VoiceCmd_CommandOther(ByVal eventSender As System.Object, ByVal eventArgs As AxHSRLib._VcommandEvents_CommandOtherEvent) Handles VoiceCmd.CommandOther
  100.         'If commands other than those listed in our menu are heard Display them
  101.         Timer1.Enabled = False
  102.         Detect.Text = eventArgs.Command
  103.         Timer1.Enabled = True
  104.         Timer1.Interval = 2000
  105.     End Sub
  106.  
  107.     Private Sub Voicecmd_CommandRecognize(ByVal eventSender As System.Object, ByVal eventArgs As AxHSRLib._VcommandEvents_CommandRecognizeEvent) Handles Voicecmd.CommandRecognize
  108.         ' One of our listed commands has been spoken
  109.         Timer1.Enabled = False
  110.         ' Display it.
  111.         Detect.Text = eventArgs.Command
  112.         ' Look for it in a list and execute the relavant commands
  113.         Select Case UCase(eventArgs.Command)
  114.             Case "OPEN"
  115.                 Cmd_Open_Click(Cmd_Open, New System.EventArgs())
  116.             Case "SAVE"
  117.                 Cmd_Save_Click(Cmd_Save, New System.EventArgs())
  118.             Case "EXIT"
  119.                 Cmd_Exit_Click(Cmd_Exit, New System.EventArgs())
  120.             Case "STOP LISTENING"
  121.                 Cmd_Start_Click(Cmd_Start, New System.EventArgs())
  122.             Case "RED"
  123.                 Lst_Commands.BackColor = System.Drawing.ColorTranslator.FromOle(&H101FF)
  124.             Case "GREEN"
  125.                 Lst_Commands.BackColor = System.Drawing.ColorTranslator.FromOle(&H1FF01)
  126.             Case "BLUE"
  127.                 Lst_Commands.BackColor = System.Drawing.ColorTranslator.FromOle(&HFF0101)
  128.             Case "WHITE"
  129.                 Lst_Commands.BackColor = System.Drawing.ColorTranslator.FromOle(&HFFFFFF)
  130.         End Select
  131.         ' if we not exiting then reset the timer.
  132.         If Not (UCase(eventArgs.Command) = "EXIT") Then
  133.             Timer1.Enabled = True
  134.             Timer1.Interval = 2000
  135.         End If
  136.     End Sub
  137.  
  138.     Private Sub VoiceCmd_VUMeter(ByVal eventSender As System.Object, ByVal eventArgs As AxHSRLib._VcommandEvents_VUMeterEvent) Handles VoiceCmd.VUMeter
  139.         ' This Procedure is called +- every 8 seconds.
  140.         ' set the level of out vu meter..
  141.         If VU_Meter.Maximum < eventArgs.Level Then VU_Meter.Maximum = eventArgs.Level
  142.         VU_Meter.Value = eventArgs.Level
  143.     End Sub
  144. End Class
I have voice regnocnition SDK, Windows vista premium

I have also tried to run as admin but it still don't work.

How do I fix this?
Dec 28 '07 #1
2 3014
Dököll
2,364 Expert 2GB
HRESULT: 0x80030005 (STG_E_ACCESSDENIED.

I have voice regnocnition SDK, Windows vista premium

I have also tried to run as admin but it still don't work.

How do I fix this?
Hello, patr0805!

It sounds like it is restricting you as not having access. Can you give us a little background on what you are trying to achieve?

Nice bit of code, by the way, not sure how to work it, but you may find ideas here, perhaps the code is not doing what you need.

Please do stay tuned even if you hadn't heard from me, someone should see your post..

In a bit
Dec 28 '07 #2
I am trying to make the application react on voice commands
Dec 28 '07 #3

Post your reply

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

Similar topics

reply views Thread by Bootstrap Bill | last post: by
reply views Thread by Xarky | last post: by
3 posts views Thread by BobAchgill | last post: by
1 post views Thread by Junior | last post: by
reply views Thread by RobertJohn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.