Hi Leuts,
bastle grad bissl mit den Directsr rum.
Bis jetzt gehts ganz gut aber das Original Microsoft Voice geht wesentlich besser als das mit VB ?! Ist aber das gleiche Modul.
Hier mal etwas Code zum Basteln.
Code:Option Explicit '-------------------------------api declares----------------------------------- 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 "Disable" DirectSR1.Deactivate Command1.Caption = "Enable" Label1 = "Disabled" Case "Enable" DirectSR1.Activate Command1.Caption = "Disable" Label1 = "Ready" End Select End Sub Private Sub Command2_Click() DirectSS1.Speak Format(Time, "hh:mm") 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) 'MsgBox "in the phrasefinish" Dim sFile As String Dim noth As Long 'MsgBox Phrase, , "The Phrase is: " Select Case Phrase Case "Notepad" sFile = "\system32\notepad.exe" noth = ShellExecute(0, "OPEN", Environ("SystemRoot") & sFile, "", "", 1) Case "Volume" sFile = "\system32\sndvol32.exe" noth = ShellExecute(0, "OPEN", Environ("SystemRoot") & sFile, "", "", 1) Case "Media Player:" sFile = "C:\Program Files\Windows Media Player\mplayer2.exe" noth = ShellExecute(0, "OPEN", sFile, "", "", 1) Case "Time" DirectSS1.Speak Format(Time, "hh:mm") End Select If Phrase <> "" Then Text1.Text = "Matched word is " & Phrase 'DirectSR1.LastHeard = "" Else Text1.Text = "No word matched" 'DirectSR1.LastHeard = "" End If 'DirectSR1.Activate End Sub Private Sub Form_Load() Dim retval As Integer DirectSR1.GrammarFromString "[Grammar]" + vbNewLine + _ "type=cfg" + vbNewLine + _ "[<start>]" + vbNewLine + _ "<start>=Web Browser" + vbNewLine + _ "<start>=Notepad" + vbNewLine + _ "<start>=Visual Basic" + vbNewLine + _ "<start>=Calculator" + vbNewLine + _ "<start>=Time" + vbNewLine DirectSR1.Activate End Sub ]
Also man könnte da schon viel machen ála Roboter und in Verbindung Directss
Hier noch die Links für die benötigten Komponeten.
http://download.microsoft.com/downlo...I4SDKSUITE.exe
http://download.microsoft.com/downlo...peechsdk51.exe
Würd mich freuen wenn da mehr interesse hätten
by Ulli
PS: geht nur in English







Zitieren

Lesezeichen