我在大富翁论坛问过这个问题了,不过没人回答.
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3562070问题如下:我用delphi,ms的TTS,想将内容保存为WAV文件,sdk说明档里面的没有delphi的例子,
有个VB的例子比较容易参考:
Dim FileName As String
Dim FileStream As New SpFileStream
Dim Voice As  SpVoice'Create a  SAPI voice
Set Voice = New SpVoice
 
'The output audio data will be saved to ttstemp.wav file
FileName = “c:\ttstemp.wav"
 
'Create a file; set DoEvents=True so TTS events will be saved to the file
FileStream.Open FileName, SSFMCreateForWrite, True  ***********'Set the output to the FileStream
Set Voice.AudioOutputStream = FileStream  *************
 
'Speak the text
Voice.Speak “hello world”'Close the Stream
FileStream.Close'Release the objects
Set FileStream = Nothing
Set Voice = Nothing  
问题出在改写上面******的内容的时候,
我写成:
var FileStream : SpFileStream
FileStream.open(FileName, SSFMCreateForWrite, True);
的话会出错.显示是incompatible type:'TSpFileStream' and 'ISpeechBaseStream',
根据上面的代码,Voice.AudioOutputStream = FileStream ,应该是直接赋值的呀!根据SDK说明:
AudioOutputStream Property  Syntax:
SpVoice.AudioOutputStream = ISpeechBaseStream 而ISpeechBaseStream 的说明是:The ISpeechBaseStream automation interface defines properties and methods for manipulating data streams.
The ISpeechBaseStream is not an object in its own right, but is implemented by other objects, such as SpFileStream and SpMemoryStream. SAPI does not call ISpeechBaseStream methods, but uses the underlying COM interfaces. For this reason, a custom object cannot be created using the ISpeechBaseStream interface.也就是说TSpFileStream应该和ISpeechBaseStream 之间是不用转换就可以直接赋值的吧??上面的sdk说明档只是节选了部分我认为是重要的,完整点的在我DELPHIBBS论坛上面的连接有:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3562070谁有过类似经验的请指点一下.