www.pudn.com > speech_test.rar > Form1.frm


VERSION 5.00 
Begin VB.Form Form1  
   BackColor       =   &H00E0E0E0& 
   Caption         =   "Form1" 
   ClientHeight    =   5700 
   ClientLeft      =   60 
   ClientTop       =   450 
   ClientWidth     =   8355 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   5700 
   ScaleWidth      =   8355 
   StartUpPosition =   3  '窗口缺省 
   Begin VB.TextBox Text1  
      Height          =   1215 
      Left            =   600 
      TabIndex        =   1 
      Top             =   1320 
      Width           =   1500 
   End 
   Begin VB.CommandButton Command1  
      Caption         =   "测试" 
      Height          =   375 
      Left            =   6240 
      TabIndex        =   0 
      Top             =   5040 
      Width           =   1455 
   End 
   Begin VB.Label Label1  
      BackColor       =   &H00E0E0E0& 
      BackStyle       =   0  'Transparent 
      Caption         =   "通过“左”“右”“上””下“口令语音控制红色方块运动" 
      Height          =   495 
      Left            =   120 
      TabIndex        =   2 
      Top             =   240 
      Width           =   5055 
   End 
   Begin VB.Shape Shape1  
      FillColor       =   &H000000FF& 
      FillStyle       =   0  'Solid 
      Height          =   735 
      Left            =   6720 
      Top             =   2520 
      Width           =   735 
   End 
End 
Attribute VB_Name = "Form1" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Dim WithEvents RecoContext As SpSharedRecoContext 
Attribute RecoContext.VB_VarHelpID = -1 
Dim Grammar As ISpeechRecoGrammar 
 
Private Sub Form_Load() 
m_cChars = 0 
Set RecoContext = New SpSharedRecoContext 
        Set Grammar = RecoContext.CreateGrammar(1) 
        Grammar.DictationLoad 
        Grammar.DictationSetState SGDSActive 
 
End Sub 
 
Private Sub RecoContext_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult) 
Dim strText As String 
Dim py As String 
    strText = Result.PhraseInfo.GetText 
    
   py = GetCode(strText) 
   Select Case py 
 
  Case "jj" 
     strText = "左" 
Shape1.Left = Shape1.Left + 1000 
   Case "sk" 
    
        strText = "右" 
   Shape1.Left = Shape1.Left - 1000 
     
     Case "s" 
      strText = "上" 
  Shape1.Top = Shape1.Top - 1000 
     
   Case "x" 
         strText = "下" 
           Shape1.Top = Shape1.Top + 1000 
 
  End Select 
    Text1.SelStart = m_cChars 
   Text1.SelText = strText & " " 
    m_cChars = m_cChars + 1 + Len(strText) 
     
  
 
End Sub