delphi 下用MS tts 如何保存为WAV文件

bill_zzx 2006-09-06 01:26:46
我在大富翁论坛问过这个问题了,不过没人回答.
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

谁有过类似经验的请指点一下.
...全文
328 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
netseek 2006-09-09
  • 打赏
  • 举报
回复
网上有个语音朗读开发包,里面有DELPHI例子,可以实现你的问题
www.smartysoft.cn/smartreadsdk/
bill_zzx 2006-09-09
  • 打赏
  • 举报
回复
你个个问题都发广告也不觉得累阿.
我只是想自己做个自己用的程序,买你的SDK要花几百块划不来
bill_zzx 2006-09-08
  • 打赏
  • 举报
回复
好像这样不得.也不知道是怎么回事,VB中都可以直接赋值了
luxuewei5214 2006-09-07
  • 打赏
  • 举报
回复
简单看了一下,这方面也不是很熟,ISpeechBaseStream是个接口,你可以创建个他的对象,在接收了文件流以后再想办法从这个对象中把流存入文件

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧