Vb.net 这是visual basic中声音识别的正确代码吗

Vb.net 这是visual basic中声音识别的正确代码吗,vb.net,audio,Vb.net,Audio,我想确保这段代码在vb接收到用户声音时获得音频电平值 当我运行这段代码和在另一个类中调用函数时,我有一些警告 获取声音识别码的音频电平值: Imports System.Speech Imports System.Speech.Recognition Imports AxShockwaveFlashObjects.AxShockwaveFlash Imports AxShockwaveFlashObjects Public Class sound1 Private recognizer As

我想确保这段代码在vb接收到用户声音时获得音频电平值

当我运行这段代码和在另一个类中调用函数时,我有一些警告

获取声音识别码的音频电平值:

Imports System.Speech
Imports System.Speech.Recognition
Imports AxShockwaveFlashObjects.AxShockwaveFlash
Imports AxShockwaveFlashObjects

Public Class sound1
Private recognizer As New SpeechRecognitionEngine()

Dim value As Boolean

Sub recognizer_AudioLevelUpdated(ByVal sender As Object, ByVal e As AudioLevelUpdatedEventArgs)

    recognizer = New SpeechRecognitionEngine
    recognizer.LoadGrammar(New Grammar(New GrammarBuilder("just nothing")))
    ' the warning at the above line " InvalidOperationException Was unhandled - The language for the grammar does not match the language of the speech recognizer."  
    AddHandler recognizer.AudioLevelUpdated, AddressOf recognizer_AudioLevelUpdated
    recognizer.SetInputToDefaultAudioDevice()
    recognizer.RecognizeAsync(RecognizeMode.Multiple)
    value = e.AudioLevel
    Do While value > 70
        'Console.WriteLine(value)
        MessageBox.Show(value)
     Loop
     End Sub
     End Class
调用音频级别功能:

Imports System.Speech.Recognition
Imports System.Speech.Recognition.GrammarBuilder
Imports AxShockwaveFlashObjects.AxShockwaveFlash
Imports AxShockwaveFlashObjects

Public Class flashWithSound
Dim s As New sound1
Dim sender As Object
Dim e As AudioLevelUpdatedEventArgs


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


End Sub

Private Sub AxShockwaveFlash1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxShockwaveFlash1.Enter

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    s.recognizer_AudioLevelUpdated(sender, e)
' the warning at the above line "InvalidCastException Was unhandled - couldn't convert object from type 'System.Windows.Forms.MouseEventArgs' to type 'System.Speech.Recognition.AudioLevelUpdatedEventArgs'."
End Sub

End Class

因此,我如何修复这些警告,请,

System.Speech.Recognition.AudioLevelUpdateEventArgs的事件参数与
System.Windows.Forms.MouseeEventArgs
不同。您不能让按钮单击事件处理
AudioLevelEvent
这样的事件。
只要写一个单独的小组来处理这件事,你就应该准备好了。

如果他们只知道有“一些警告”,那他们怎么能帮上忙呢?消息是什么?它出现在哪里?我提到,在代码中作为注释,关注代码!你的意思是我必须改变工具而不是按钮,或者改变按钮的事件??那么第一个代码中关于语法的警告呢?非常感谢你