pb12中如何使用ms的TTS?

evergod82 2011-11-01 03:57:53
如题,在pb中如何使用MS的TTS!?
...全文
217 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wlj768 2011-11-01
  • 打赏
  • 举报
回复
还没用到,存起来以后用。
yyoinge 2011-11-01
  • 打赏
  • 举报
回复
然后自己到网上找tts语音包

这里面有tts
http://www.lingoes.cn/zh/translator/speech.htm
yyoinge 2011-11-01
  • 打赏
  • 举报
回复
接上面,一起复制,再保存导入

type cb_6 from commandbutton within w_read
integer x = 558
integer y = 968
integer width = 402
integer height = 120
integer taborder = 110
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "朗读文本"
end type

event clicked;string ls_importfilepath,ls_importfilename
long ll_FLength,ll_FileNum
string ls_filecontext,ls_tmp
int i,loops,j
ll_FileNum = GetFileOpenName ("选择文本文件" ,ls_importfilepath,ls_importfilename, "txt" , "文本文件(*.txt),*.txt")
ll_FLength = filelength(ls_importfilepath)
IF ll_FLength > 32765 THEN
IF mod(ll_FLength,32765) = 0 THEN
loops= ll_FLength/32765
ELSE
loops= ll_FLength/32765 +1
END IF
ELSE
loops=1
END IF
IF ll_FileNum <> 1 THEN
messagebox ("选择文件信息","没有选择文件!")
ELSE
ll_FileNum = FileOpen(ls_importfilepath,StreamMode!, Read!, LockWrite!, Replace!)
IF ll_FileNum <> 1 THEN
messagebox ("错误信息","文件没打开!")
ELSE
// read file
SetPointer(hourglass!)
FOR i=1 TO loops
j=FileRead(ll_filenum,ls_tmp)
ls_filecontext=ls_filecontext + ls_tmp
NEXT
FileClose(ll_FileNum)
mle_1.text=ls_filecontext
tts.speak(" ", "2")
tts.speak(ls_filecontext , "1")
END IF
END IF
end event

type cb_5 from commandbutton within w_read
integer x = 558
integer y = 804
integer width = 402
integer height = 120
integer taborder = 100
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "下一句"
end type

event clicked;tts.skip ("sentence" ,1)
end event

type cb_4 from commandbutton within w_read
integer x = 558
integer y = 640
integer width = 402
integer height = 120
integer taborder = 100
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "上一句"
end type

event clicked;tts.skip ("sentence" ,-1)
end event

type cb_3 from commandbutton within w_read
integer x = 64
integer y = 968
integer width = 402
integer height = 120
integer taborder = 90
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "暂停"
end type

event clicked;IF cb_3.text="暂停" THEN
tts.pause()
cb_3.text="继续"
ELSE
tts.resume()
cb_3.text="暂停"
cb_1.enabled=true
END IF
end event

type cb_2 from commandbutton within w_read
integer x = 64
integer y = 804
integer width = 402
integer height = 120
integer taborder = 80
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "停止"
end type

event clicked;tts.speak("" , "2")
cb_2.enabled=false
cb_3.enabled=false
end event

type cb_1 from commandbutton within w_read
integer x = 64
integer y = 640
integer width = 402
integer height = 120
integer taborder = 70
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "朗读"
end type

event clicked;integer li_ret
IF mle_1.text="" THEN
messagebox ("错误信息","没有内容朗读!")
ELSE
//中止先前朗读
tts.speak("" , "2")
//朗读
li_ret = tts.speak(mle_1.text,"1")
cb_2.enabled=true
cb_3.enabled=true
END IF
end event

type mle_1 from multilineedit within w_read
integer x = 1097
integer y = 24
integer width = 2290
integer height = 1480
integer taborder = 60
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean hscrollbar = true
boolean vscrollbar = true
borderstyle borderstyle = stylelowered!
end type

type htb_2 from htrackbar within w_read
integer x = 224
integer y = 392
integer width = 763
integer height = 128
integer minposition = -10
integer maxposition = 10
integer tickfrequency = 10
end type

event moved;tts.rate=this.position
end event

type htb_1 from htrackbar within w_read
integer x = 224
integer y = 240
integer width = 768
integer height = 128
integer maxposition = 100
integer position = 100
integer tickfrequency = 10
end type

event moved;tts.Volume=this.position
end event

type ddlb_2 from dropdownlistbox within w_read
integer x = 215
integer y = 136
integer width = 782
integer height = 328
integer taborder = 60
integer textsize = -10
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean vscrollbar = true
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;if index > 0 then tts.AudioOutput = tts.GetAudioOutputs.Item(index - 1)
end event

type gb_1 from groupbox within w_read
integer y = 548
integer width = 1047
integer height = 628
integer taborder = 70
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 67108864
string text = "朗读操作"
end type

yyoinge 2011-11-01
  • 打赏
  • 举报
回复
保存为本地文件w_read.srw,然后导入pbl中
$PBExportHeader$w_read.srw
forward
global type w_read from window
end type
type mle_2 from multilineedit within w_read
end type
type ddlb_1 from dropdownlistbox within w_read
end type
type st_4 from statictext within w_read
end type
type st_3 from statictext within w_read
end type
type st_2 from statictext within w_read
end type
type st_1 from statictext within w_read
end type
type cb_6 from commandbutton within w_read
end type
type cb_5 from commandbutton within w_read
end type
type cb_4 from commandbutton within w_read
end type
type cb_3 from commandbutton within w_read
end type
type cb_2 from commandbutton within w_read
end type
type cb_1 from commandbutton within w_read
end type
type mle_1 from multilineedit within w_read
end type
type htb_2 from htrackbar within w_read
end type
type htb_1 from htrackbar within w_read
end type
type ddlb_2 from dropdownlistbox within w_read
end type
type gb_1 from groupbox within w_read
end type
end forward

global type w_read from window
integer width = 3406
integer height = 1648
boolean titlebar = true
string title = "调用微软MSTTS语音引擎实例"
boolean controlmenu = true
boolean minbox = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
mle_2 mle_2
ddlb_1 ddlb_1
st_4 st_4
st_3 st_3
st_2 st_2
st_1 st_1
cb_6 cb_6
cb_5 cb_5
cb_4 cb_4
cb_3 cb_3
cb_2 cb_2
cb_1 cb_1
mle_1 mle_1
htb_2 htb_2
htb_1 htb_1
ddlb_2 ddlb_2
gb_1 gb_1
end type
global w_read w_read

on w_read.create
this.mle_2=create mle_2
this.ddlb_1=create ddlb_1
this.st_4=create st_4
this.st_3=create st_3
this.st_2=create st_2
this.st_1=create st_1
this.cb_6=create cb_6
this.cb_5=create cb_5
this.cb_4=create cb_4
this.cb_3=create cb_3
this.cb_2=create cb_2
this.cb_1=create cb_1
this.mle_1=create mle_1
this.htb_2=create htb_2
this.htb_1=create htb_1
this.ddlb_2=create ddlb_2
this.gb_1=create gb_1
this.Control[]={this.mle_2,&
this.ddlb_1,&
this.st_4,&
this.st_3,&
this.st_2,&
this.st_1,&
this.cb_6,&
this.cb_5,&
this.cb_4,&
this.cb_3,&
this.cb_2,&
this.cb_1,&
this.mle_1,&
this.htb_2,&
this.htb_1,&
this.ddlb_2,&
this.gb_1}
end on

on w_read.destroy
destroy(this.mle_2)
destroy(this.ddlb_1)
destroy(this.st_4)
destroy(this.st_3)
destroy(this.st_2)
destroy(this.st_1)
destroy(this.cb_6)
destroy(this.cb_5)
destroy(this.cb_4)
destroy(this.cb_3)
destroy(this.cb_2)
destroy(this.cb_1)
destroy(this.mle_1)
destroy(this.htb_2)
destroy(this.htb_1)
destroy(this.ddlb_2)
destroy(this.gb_1)
end on

event open;integer n,m
string ls_desp
//取得引擎列表
m=integer(tts.getvoices.count)
IF m < 1 THEN RETURN 0
cb_1.enabled = true
cb_2.enabled = false
cb_3.enabled = false
//显示引擎
FOR n = 1 TO m
ls_desp = string(tts.getvoices.item[n - 1].getdescription())
IF n=1 THEN ddlb_1.text = ls_desp
ddlb_1.additem (ls_desp)
NEXT
//取得音频输出列表
m = tts.getaudiooutputs.count
IF m < 1 THEN RETURN -1
//显示音频输出设备
FOR n = 1 TO m
ls_desp =string(tts.getaudiooutputs.item[n - 1].getdescription())
IF n = 1 THEN ddlb_2.text = ls_desp
ddlb_2.additem(ls_desp)
NEXT
RETURN 1

end event

type mle_2 from multilineedit within w_read
integer x = 5
integer y = 1192
integer width = 1061
integer height = 316
integer taborder = 120
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 16711680
string text = "提示: 1、请先安装TTS_51_eng.msi。 2、如需其它语音,请到微软官方下载(免费的)或金山词霸下载。"
end type

type ddlb_1 from dropdownlistbox within w_read
integer x = 215
integer y = 36
integer width = 782
integer height = 324
integer taborder = 70
integer textsize = -10
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean vscrollbar = true
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;If index > 0 then tts.voice=tts.getvoices.item(index - 1)
end event

type st_4 from statictext within w_read
integer x = 18
integer y = 420
integer width = 192
integer height = 48
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 67108864
string text = "速度:"
boolean focusrectangle = false
end type

type st_3 from statictext within w_read
integer x = 18
integer y = 272
integer width = 192
integer height = 48
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 67108864
string text = "音量:"
boolean focusrectangle = false
end type

type st_2 from statictext within w_read
integer x = 18
integer y = 156
integer width = 192
integer height = 48
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 67108864
string text = "音频:"
boolean focusrectangle = false
end type

type st_1 from statictext within w_read
integer x = 18
integer y = 52
integer width = 192
integer height = 48
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 67108864
string text = "声音:"
boolean focusrectangle = false
end type

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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