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")
|