RE:DirectSR1.GrammarFromString
Publicado por
dexter (1 intervención) el 23/08/2007 13:36:54
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _
lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
Select Case Command1.Caption
Case Is = "Desactivar"
DirectSR1.Deactivate
Command1.Caption = "Activar"
Case Is = "Activar"
DirectSR1.Activate
Command1.Caption = "Desactivar"
End Select
End Sub
Private Sub DirectSR1_PhraseFinish(ByVal flags As Long, _
ByVal beginhi As Long, ByVal beginlo As Long, ByVal endhi As Long, _
ByVal endlo As Long, ByVal Phrase As String, ByVal parsed As String, _
ByVal results As Long)
Dim sFile As String
Dim noth As Long
Select Case Phrase
Case "bloc"
archi = "C:\Windows\System32\notepad.exe"
ejecuta = Shell(archi, 1)
Case "kal"
archi = "C:\Windows\System32\calc.exe"
ejecuta = Shell(archi, 1)
Case "paint"
archi = "C:\Windows\System32\mspaint.exe"
ejecuta = Shell(archi, 1)
End Select
If Phrase <> "" Then
Label1.Caption = "Palabra pronunciada " & Phrase
DirectSS1.Speak Phrase
Else
Label1.Caption = "No entiendo"
DirectSS1.Speak "No entiendo"
End If
End Sub
Private Sub Form_Load()
Dim totaldata As String
DirectSR1.GrammarFromString "[Grammar]" + vbNewLine + _
"type=cfg" + vbNewLine + _
"[<start>]" + vbNewLine + _
"<start>=rojo" + vbNewLine + _
"<start>=azul" + vbNewLine + _
"<start>=verde" + vbNewLine + _
"<start>=a" + vbNewLine + _
"<start>=e" + vbNewLine + _
"<start>=i" + vbNewLine + _
"<start>=o" + vbNewLine + _
"<start>=u" + vbNewLine + _
"<start>=bloc" + vbNewLine + _
"<start>=paint" + vbNewLine + _
"<start>=kal" + vbNewLine
DirectSR1.Activate
Command1.Caption = "Desactivar"
DirectSS1.Speak "Este programa por Dexter"
Label1.Caption = ""
End Sub