*!*实例:(注意:标点符号应与文字之间有间隔,否则可能会朗读标点)
*----------------------------------------------------------
RUN /N REGSVR32 /S COMCTL32.OCX
LOVOICE=CREATEOBJECT('sapi.spvoice') && 建立对象
DIMENSION 语音库(lovoice.GetVoices.Count)
FOR i=0 TO lovoice.GetVoices.Count-1 && 用于枚举语音库
语音库(i+1)=lovoice.getvoices.item(i).id && 语音库标志
ENDFOR
FM_DWJESET=CREATEOBJECT('DWJESET_FORM')
FM_DWJESET.SHOW(1)
DEFI CLASS DWJESET_FORM AS FORM
WIDTH =600
HEIGHT=400
AUTOCENTER=.T.
BORDERSTYLE=1
CAPTION=' 语音识别'
ADD OBJECT 表单边框 AS SHAPE WITH TOP=5 ,LEFT=5, WIDTH=590,HEIGHT=390 ,SPECIALEFFECT=0 && 大线框
ADD OBJECT 提示信息 AS LABEL WITH TOP=20 ,LEFT=20, AUTOSIZE=.T.,CAPTION='朗读内容:',BACKSTYLE=0
ADD OBJECT 朗读内容 AS EDITBOX WITH TOP=35 ,LEFT=15, WIDTH=400,HEIGHT=350,value="Enter text you wish spoken here."&& text you wish spoken here.'&&ControlSource='内容'&&,READONLY=.T.
ADD OBJECT 开始朗读 AS COMMANDBUTTON WITH TOP=230,LEFT=450,WIDTH=110,HEIGHT=24,CAPTION='开 始 朗 读'
ADD OBJECT 停止朗读 AS COMMANDBUTTON WITH TOP=270,LEFT=450,WIDTH=110,HEIGHT=24,CAPTION='停 止 朗 读'
ADD OBJECT 暂停朗读 AS COMMANDBUTTON WITH TOP=310,LEFT=450,WIDTH=110,HEIGHT=24,CAPTION='暂 停 朗 读'
ADD OBJECT 退出程序 AS COMMANDBUTTON WITH TOP=350,LEFT=450,WIDTH=110,HEIGHT=24,CAPTION='退 出 程 序'
ADD OBJECT 音库信息 AS LABEL WITH TOP=35 ,LEFT=430, AUTOSIZE=.T.,CAPTION='当前语音库:',BACKSTYLE=0
ADD OBJECT 语速信息 AS LABEL WITH TOP=93 ,LEFT=430, AUTOSIZE=.T.,CAPTION='语速:',BACKSTYLE=0
ADD OBJECT 音量信息 AS LABEL WITH TOP=153,LEFT=430, AUTOSIZE=.T.,CAPTION='音量:',BACKSTYLE=0
ADD OBJECT 语音库表 AS COMBOBOX WITH RowSource=[语音库],TOP=54,LEFT=430,WIDTH=150,HEIGHT=22,ROWSOURCETYPE=5,STYLE=2,TABSTOP=.F.,value=1
ADD OBJECT 语速控件 AS OLECONTROL WITH OLECLASS='MSComctlLib.Slider.2',TOP=110,LEFT=420,WIDTH=165,HEIGHT=22,ENABLED=.T.
ADD OBJECT 音量控件 AS OLECONTROL WITH OLECLASS='MSComctlLib.Slider.2',TOP=170,LEFT=420,WIDTH=165,HEIGHT=22,ENABLED=.T.
&&=== tts word2wav
xx=NEWOBJECT("Sapi.SpVoice")
mfs=NEWOBJECT("SAPI.SpFileStream")
mfs.Format.Type = 4
mfs.Open(this.wavfile,3,0)
* Set the .wav file stream as the output for the Voice object
xx.AudioOutputStream = mfs
xx.Rate = 10
xx.Volume = 99
xx.Speak("hello word",0)
wait 'a moment!'
mfs.Close
release xx