本页主题: 网页语音朗读设计代码三例 打印 | 加为IE收藏 | 复制链接 | 收藏主题 | 上一主题 | 下一主题

singleman
级别: 勇者侠士


精华: 0
发帖: 97
威望: 111 点
财富: 943 K币
贡献值: 0 点
注册时间:2003-08-25
最后登录:2008-05-10

 网页语音朗读设计代码三例

第一例
Copy code
<object classid="clsid:2398E32F-5C6E-11D1-8C65-0060081841DE" id="TextToSpeech1" data="DATA:application/x-oleobject;BASE64,L+OYI25c0RGMZQBgCBhB3gICAADYEwAA2BMAAA==
" width="6" height="6">
</object>
<script language="javascript">
<!--
function start(){
TextToSpeech1.Speak(document.all["main"].innerText);
}//*开始朗读
function pause(){
TextToSpeech1.Pause();
}//*暂停朗读
function resume(){
TextToSpeech1.Resume();
}//*继续朗读
function end(){
TextToSpeech1.StopSpeaking();
}//*停止朗读
//-->
</script>
<a href="javascript:void start()">朗读</a>  <a href="javascript:void pause()">暂停</a>  <a href="javascript:void resume()">继续</a>  <a href="javascript:void end()">停止</a>
顶端 Posted: 2008-05-10 20:40 | [楼 主]
singleman
级别: 勇者侠士


精华: 0
发帖: 97
威望: 111 点
财富: 943 K币
贡献值: 0 点
注册时间:2003-08-25
最后登录:2008-05-10

 

第二例
Copy code
<object classid="clsid:B8F2846E-CE36-11D0-AC83-00C04FD97575" id="TTS" data="DATA:application/x-oleobject;BASE64,boTyuDbO0BGsgwDAT9l1dQADAADYEwAA2BMAAA==">
</object>
<object classid="clsid:D45FD31B-5C6E-11D1-9EC1-00C04FD7081F" id="Agent1">
</object>
<script language="VBScript">
'载入动画精灵
Agent1.connected=true
Agent1.characters.load "merlin","merlin.acs"
set Chuboies=Agent1.characters.character("merlin")

Chuboies.commands.removeall()
Chuboies.commands.visible=true
Chuboies.commands.caption="楚布衣工作室"
Chuboies.commands.add "menu0","关于本站","关于本站"
Chuboies.commands.add "menu1","站长简介","站长简介"
Chuboies.commands.add "menu2","本站地图","本站地图"
Chuboies.commands.add "menu3","联系本站","联系本站"
Chuboies.commands.add "menu4","本站链接","本站链接"

Chuboies.show()
Chuboies.moveto screen.width/2,screen.height/2
Chuboies.play "GetAttention"
Chuboies.speak "\pit=156\\spd=156\欢迎光临“楚布衣工作室”!"
Chuboies.play "GetAttentionReturn"
Chuboies.play "Announce"
Chuboies.speak "\pit=156\\spd=156\我是“布衣精灵”,有什么需要帮助的,请点我!"
Chuboies.play "AnnounceReturn"
Chuboies.play "Greet"
Chuboies.play "GreetReturn"
Chuboies.moveto screen.width-200,screen.height-500

Sub Agent1_Command(UserInput)
'右键菜单
select case UserInput.Name
case "menu0"
msgbox "关于本站",32,"辅助菜单"
case "menu1"
msgbox "站长简介",32,"辅助菜单"
case "menu2"
msgbox "本站地图",32,"辅助菜单"
case "menu3"
msgbox "联系本站",32,"辅助菜单"
case "menu4"
msgbox "本站链接",32,"辅助菜单"
end select
End Sub

Sub Agent1_Click(CharacterID,Button,Shift,X,Y)
'精灵对话框
if Button=1 then
Chuboies.Stop
Chuboies.play "Confused"
Chuboies.speak "\pit=156\\spd=156\有什么需要我帮忙的吗?"
Chuboies.play "RestPose"
end if
End Sub

Sub Agent1_DblClick(CharacterID,Button,Shift,X,Y)
'更改精灵的位置
if Button=1 then
Chuboies.Stop
Chuboies.think "\pit=156\\spd=156\我站的位置不对吗?"
Chuboies.think "\pit=156\\spd=156\那我换一个位置吧,呵呵……"
Chuboies.moveto rnd*(screen.width-Chuboies.width),rnd*(screen.height-Chuboies.height)
end if
End Sub

Sub Agent1_DragStart(CharacterID,Button,Shift,X,Y)
'开始拖动精灵
cur_x=X-Chuboies.width/2
cur_y=Y-Chuboies.height/2
End Sub

Sub Agent1_DragComplete(CharacterID,Button,Shift,X,Y)
'停止拖动精灵
Chuboies.stop
Chuboies.play "Confused"
Chuboies.speak "\pit=156\\spd=156\请不要再拖动我,可以吗?"
Chuboies.play "RestPose"
Chuboies.moveto cur_x,cur_y
End Sub

Sub Window_Unload()
'删除动画精灵
set Chuboies=nothing
Agent1.connected=false
End Sub
</script>
顶端 Posted: 2008-05-10 20:42 | 1 楼
singleman
级别: 勇者侠士


精华: 0
发帖: 97
威望: 111 点
财富: 943 K币
贡献值: 0 点
注册时间:2003-08-25
最后登录:2008-05-10

 

第三例
Copy code
源代码:(请确认您的电脑装载了微软的“Direct Text-to-Speech”控件)
<object classid="clsid:EEE78591-FE22-11D0-8BEF-0060081841DE" id="DirectSS1" data="DATA:application/x-oleobject;BASE64,kYXn7iL+0BGL7wBgCBhB3gICAADYEwAA2BMAAAIAAAACAAAAAgC0AAIAggAC
AAAAAgAyAAIA5gACAPAAAgAAAAIAAQACAAEAAgABAAIAAAA=
" width="1" height="1">
</object>//*引用微软的“Direct Text-to-Speech”控件,此为能朗读的关键
<script language="javascript">
<!--
function readall(){
DirectSS1.speak(document.all["main"].innerText);
}//*朗读main中的文字
function readtext(srcElement){
DirectSS1.speak(srcElement.innerText);
}//*鼠标移到srcElement上,触发朗读
function outtext(){
DirectSS1.speak("");
}//*鼠标移开停止朗读
//-->
</script>

顶端 Posted: 2008-05-10 20:44 | 2 楼
帖子浏览记录 版块浏览记录
IECN社区 » JavaScript/Ajax

Time now is:01-09 03:43, Gzip disabled 京ICP备06069722号
Powered by PHPWind v6.3.2 Certificate Code © 2003-08 PHPWind.com Corporation