Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Speech.Recognition
- Imports System.Speech.Recognition.SrgsGrammar
- Public Class Form1
- Private recognizer As SpeechRecognizer
- Public Sub New()
- ' This call is required by the designer.
- InitializeComponent()
- recognizer = New SpeechRecognizer()
- ' Add any initialization after the InitializeComponent() call.
- AddHandler recognizer.SpeechDetected, AddressOf recognizer_SpeechDetected
- AddHandler recognizer.SpeechRecognitionRejected, AddressOf recognizer_SpeechRecognitionRejected
- AddHandler recognizer.SpeechRecognized, AddressOf recognizer_SpeechRecognized
- Dim grammar As New GrammarBuilder()
- grammar.Append(New Choices("queue", "tag", "draft"))
- grammar.Append(New Choices("madoka", "kill la kill", "kyoukai no kanata", "back", " "))
- recognizer.LoadGrammar(New Grammar(grammar))
- End Sub
- Private Sub recognizer_SpeechRecognized(ByVal sender As Object, ByVal e As SpeechRecognizedEventArgs)
- Select Case e.Result.Text.ToUpper
- Case Is = "tag madoka"
- AppActivate("chrome.exe")
- SendKeys.Send("t")
- SendKeys.Send("pmmm")
- SendKeys.Send("{TAB}{TAB}")
- SendKeys.Send("r")
- Case Is = "tag kill la kill"
- SendKeys.Send("t")
- SendKeys.Send("klk")
- SendKeys.Send("{TAB}{TAB}")
- SendKeys.Send("r")
- Case Is = "tag kyoukai no kanata"
- SendKeys.Send("t")
- SendKeys.Send("knk")
- SendKeys.Send("{TAB}{TAB}")
- SendKeys.Send("r")
- Case Is = "draft madoka"
- SendKeys.Send("t")
- SendKeys.Send("pmmm")
- SendKeys.Send("{TAB}{TAB}")
- SendKeys.Send("d")
- Case Is = "draft kill la kill"
- SendKeys.Send("t")
- SendKeys.Send("klk")
- SendKeys.Send("{TAB}{TAB}")
- SendKeys.Send("d")
- Case Is = "draft kyoukai no kanata"
- SendKeys.Send("t")
- SendKeys.Send("knk")
- SendKeys.Send("{TAB}{TAB}")
- SendKeys.Send("d")
- Case Is = "queue madoka"
- SendKeys.Send("t")
- SendKeys.Send("pmmm")
- SendKeys.Send("{TAB}{TAB}")
- SendKeys.Send("q")
- Case Is = "queue kill la kill"
- SendKeys.Send("t")
- SendKeys.Send("klk")
- SendKeys.Send("{TAB}{TAB}")
- SendKeys.Send("q")
- Case Is = "queue kyoukai no kanata"
- SendKeys.Send("t")
- SendKeys.Send("knk")
- SendKeys.Send("{TAB}{TAB}")
- SendKeys.Send("q")
- Case Is = "back"
- SendKeys.Send("k")
- End Select
- End Sub
- Dim speaking As Boolean
- Private Function CheckIfSpeaking() As Boolean
- If speaking = False Then
- Threading.Thread.Sleep(2000)
- SendKeys.Send("j")
- Return True
- Else
- Return False
- End If
- End Function
- Private Sub recognizer_SpeechDetected(ByVal sender As Object, ByVal e As SpeechDetectedEventArgs)
- speaking = True
- End Sub
- Private Sub recognizer_SpeechRecognitionRejected(ByVal sender As Object, ByVal e As SpeechRecognitionRejectedEventArgs)
- speaking = False
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement