找回密码
 加入
搜索
查看: 3527|回复: 7

怎样调用语音包实现读取计算机名

  [复制链接]
发表于 2008-9-2 01:17:17 | 显示全部楼层 |阅读模式
我在论坛看有个发幽忧网管呼叫中心作品带语音的

[ 本帖最后由 jiangzhanye 于 2008-12-26 19:21 编辑 ]
发表于 2008-9-2 01:22:46 | 显示全部楼层
好像也不难啊,读取计算名,对应语音文件名,然后运行语音就行了,是吧?
 楼主| 发表于 2008-9-2 01:25:15 | 显示全部楼层
是的
能大概说下吗
发表于 2008-9-2 08:58:26 | 显示全部楼层
 
Local $ClientName, $Speak[20]
Local $AudioPath = @ScriptDir & "\"
;设置号码数组
For $i = 0 To 10
 $Speak[$i] = $AudioPath & $i & ".wav"
Next
$Speak[11] = $AudioPath & "100.wav"
$Speak[12] = $AudioPath & "hao.wav"
$Speak[13] = $AudioPath & "help.wav"

;读机器号码
Func _Play($Num)
;~  Local $Play[4]
 $Num = _ReturnInt($Num)
 $len = StringLen($Num)
 If StringLen($Num) = 2 Or StringLen($Num) = 3 And StringRight($Num,2) = "00" Then
  _SpeakTenPlay($Num)
 Else
  For $i = 1 To $len
   $s = StringMid($Num, $i, 1)
   _SpeakPlay($s, $len - $i)
  Next
 EndIf
 SoundPlay($Speak[12], 1)
 SoundPlay($Speak[13], 1)
EndFunc   ;==>_Play

;10到和整百数字的发音
Func _SpeakTenPlay($s)
 If $s = "10" Then
  SoundPlay($Speak[10],1)
 ElseIf StringMid($s,2,2) = "00" Then
  SoundPlay($Speak[StringLeft($s,1)],1)
  SoundPlay($Speak[11],1)
 Else
  SoundPlay($Speak[10],1)
  SoundPlay($Speak[StringMid($s,2,1)],1)
 EndIf
EndFunc
;其他任意1000以下数字的发音
Func _SpeakPlay($s, $Units)
 Switch $Units
  Case 0
   If $s <> "0" Then
    SoundPlay($Speak[$s], 1)
   EndIf
  Case 1
   If $s = "0" Then
    SoundPlay($Speak[0], 1)
   Else
    SoundPlay($Speak[$s], 1)
    SoundPlay($Speak[10], 1)
   EndIf
  Case 2
   SoundPlay($Speak[$s], 1)
   SoundPlay($Speak[11], 1)
 EndSwitch
EndFunc   ;==>_SpeakPlay
Func _ReturnInt($Num)
 Local $tmp
 For $i = 1 To StringLen($Num)
  If StringMid($Num, $i, 1) <> 0 Then
   $tmp = StringRight($Num, StringLen($Num)  - $i + 1)
   ExitLoop
  EndIf
 Next
 Return $tmp
EndFunc   ;==>_ReturnInt

_Play("999")
_Play("50")
发表于 2008-9-2 09:00:06 | 显示全部楼层
是这样吗

#include <GUIConstants.au3>
#include <Sound.au3>


FileInstall("1.wav",@WindowsDir & "\",1)
FileInstall("hao.wav",@WindowsDir & "\",1)
FileInstall("HELP.wav",@WindowsDir & "\",1)
SoundPlay(@WindowsDir & "\1.wav");
sleep(600)
soundPlay (@WindowsDir & "\hao.wav");
sleep(1000)
soundPlay (@WindowsDir & "\HELP.wav");


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("清理垃圾工具", 569, 383, 193, 125)
$Button1 = GUICtrlCreateButton("刷      新", 464, 16, 89, 25, 0)
$Button2 = GUICtrlCreateButton("开始清理", 464, 56, 89, 25, 0)
$Button3 = GUICtrlCreateButton("退      出", 464, 120, 89, 25, 0)
$Button4 = GUICtrlCreateButton("关      于", 464, 160, 89, 25, 0)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
        
$nMsg = GUIGetMsg()
        Switch $nMsg
Case $GUI_EVENT_CLOSE,$Button3
Exit

EndSwitch
WEnd

Func del()
FileDelete(@WindowsDir & "\1.wav")
FileDelete(@WindowsDir & "\hao.wav")
FileDelete(@WindowsDir & "\help.wav")

EndFunc
发表于 2008-9-2 14:06:45 | 显示全部楼层
来晚了。Bone写得很好。
发表于 2008-9-2 21:46:17 | 显示全部楼层
如果不介意发音不准的问题,基本上可以用sapi.spvoice来读(它不能读中文,不过你可以拼些无意义的字符串来让它读起来像中文,有点意思的)
 楼主| 发表于 2008-9-3 01:07:47 | 显示全部楼层
谢谢Bone写的真好!弄几个好听美女的语音包就更完美了呵
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-22 01:11 , Processed in 0.075723 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表