#Region "语音识别http://www.microsoft.com/speech/download/sdk51/ ing"
' Dim WithEvents Rc As SpeechLib.SpSharedRecoContext
' Dim RG As ISpeechRecoGrammar
Public Sub SpeechRead(ByVal Str As String)
Dim voice As SpVoice = New SpVoice
Dim spFlags As SpeechVoiceSpeakFlags = SpeechVoiceSpeakFlags.SVSFDefault
voice.Voice = voice.GetVoices(String.Empty, String.Empty).Item(3) '024 E////3 chinese
voice.Speak(Str, SpeechVoiceSpeakFlags.SVSFDefault)
End Sub
Public Sub SpeechtoWave(ByVal Str As String)
Dim voice As SpVoice = New SpVoice
voice.Voice = voice.GetVoices(String.Empty, String.Empty).Item(3)
Dim SFd As New SaveFileDialog
SFd.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav"
SFd.Title = "Save to a wave File"
SFd.FilterIndex = 2
SFd.RestoreDirectory = True
If SFd.ShowDialog = DialogResult.OK Then
Dim spfileMode As SpeechStreamFileMode = SpeechStreamFileMode.SSFMCreateForWrite
Dim sfstream As SpFileStream = New SpFileStream
sfstream.Open(SFd.FileName, spfileMode, False)
voice.AudioOutputStream = sfstream
voice.Speak(Str, SpeechVoiceSpeakFlags.SVSFDefault)
voice.WaitUntilDone(Timeout.Infinite)
sfstream.Close()
End If
End Sub
'Public Sub tingMyspeech()
' RG = Rc.CreateGrammar
' RG.CmdSetRuleIdState(0, SpeechRuleState.SGDSActive)
'End Sub
'Private Sub hearCMD(ByVal streamNumber As Integer, ByVal streamPosition As Object, ByVal RecognitionType As SpeechRecognitionType, ByVal Shengyin As ISpeechRecoResult) Handles Rc.Recognition
' 'Rc.Voice.Speak("I hear " & Shengyin.PhraseInfo.GetText, 11)
'End Sub
#End Region