A
AK-47
Unregistered / Unconfirmed
GUEST, unregistred user!
用SAPI 语音包将文字读出没问题,但是不能保存为wav文件!!
关键控件 TSpFileStream,SpVoice1,SpMMAudioOut1
帮助的VB代码可以,但是转到delphi后就不行啊~~~晕~~~啊!!!!!!
------------------------------------------------------------------
vb代码
-------------------------------------------------------------------
Private Sub SaveToWav()
' Create a wave stream
Dim cpFileStream As New SpFileStream
' Set audio format
cpFileStream.Format.Type = SAFT22kHz16BitMono
' Call the Common File Dialog control which is inserted into the form to
' select a name for the .wav file.
ComDlg.CancelError = True
On Error GoTo Cancel
ComDlg.Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist + cdlOFNNoReadOnlyReturn
ComDlg.DialogTitle = "Save to a Wave File"
ComDlg.Filter = "All Files (*.*)|*.*|Wave Files " & "(*.wav)|*.wav"
ComDlg.FilterIndex = 2
ComDlg.ShowSave
' Create a new .wav file for writing. False indicates that we're not
' interested in writing events into the .wav file.
' Note - this line of code will fail if the file exists and is currently open.
cpFileStream.Open ComDlg.FileName, SSFMCreateForWrite, False
' Set the .wav file stream as the output for the Voice object
Set Voice.AudioOutputStream = cpFileStream //注意这句的赋值,在delphi里死硬不能这样做,因为Voice.AudioOutputStream是个接口,而cpFileStream是一个实现该接口的类的实例.---晕,变态~~!!!
' Calling the Speak method now will send the output to the "SimpTTS.wav" file.
' We use the SVSFDefault flag so this call does not return until the file is
' completely written.
Voice.Speak TextField.Text, SVSFDefault
' Close the file
cpFileStream.Close
Set cpFileStream = Nothing
' Reset the Voice object's output to 'Nothing'. This will force it to use
' the default audio output the next time.
Set Voice.AudioOutputStream = Nothing
Cancel:
Exit Sub
End Sub
----------------------------------------------------------------
关键控件 TSpFileStream,SpVoice1,SpMMAudioOut1
帮助的VB代码可以,但是转到delphi后就不行啊~~~晕~~~啊!!!!!!
------------------------------------------------------------------
vb代码
-------------------------------------------------------------------
Private Sub SaveToWav()
' Create a wave stream
Dim cpFileStream As New SpFileStream
' Set audio format
cpFileStream.Format.Type = SAFT22kHz16BitMono
' Call the Common File Dialog control which is inserted into the form to
' select a name for the .wav file.
ComDlg.CancelError = True
On Error GoTo Cancel
ComDlg.Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist + cdlOFNNoReadOnlyReturn
ComDlg.DialogTitle = "Save to a Wave File"
ComDlg.Filter = "All Files (*.*)|*.*|Wave Files " & "(*.wav)|*.wav"
ComDlg.FilterIndex = 2
ComDlg.ShowSave
' Create a new .wav file for writing. False indicates that we're not
' interested in writing events into the .wav file.
' Note - this line of code will fail if the file exists and is currently open.
cpFileStream.Open ComDlg.FileName, SSFMCreateForWrite, False
' Set the .wav file stream as the output for the Voice object
Set Voice.AudioOutputStream = cpFileStream //注意这句的赋值,在delphi里死硬不能这样做,因为Voice.AudioOutputStream是个接口,而cpFileStream是一个实现该接口的类的实例.---晕,变态~~!!!
' Calling the Speak method now will send the output to the "SimpTTS.wav" file.
' We use the SVSFDefault flag so this call does not return until the file is
' completely written.
Voice.Speak TextField.Text, SVSFDefault
' Close the file
cpFileStream.Close
Set cpFileStream = Nothing
' Reset the Voice object's output to 'Nothing'. This will force it to use
' the default audio output the next time.
Set Voice.AudioOutputStream = Nothing
Cancel:
Exit Sub
End Sub
----------------------------------------------------------------