[按键精灵] 纯文本查看 Import "zm.luae"
Import "Cjson.lua"
Dim 朗读文本="我是紫猫学院的学员,编号:1027.本人QQ:822641801.本人承接Post等"
Call 朗读(朗读文本, 15000, 4, 5, 5, 4)
/*参数:
sd:朗读时长,单位毫秒
spd:语速,取值0-9,默认为5中语速
pit:音调,取值0-9,默认为5中语调
vol:音量,取值0-9,默认为5中音量
per:发音人选择, 0为普通女声,1为普通男生,3为情感合成-度逍遥,4为情感合成-度丫丫,默认为普通女声
*/
Sub 朗读(txt,sd,spd,pit,vol,per)'朗读时间:秒
Dim Path,Urls,talbeV,cuid,PostData,Url1,Htmltxt
Path = "/sdcard/Pictures/Read.mp3"
Dim arr=array(spd,pit,vol,per)
For Each s In Arr
If s <0 or s > 9 Then TracePrint s,"参数有超出范围"
Next
Urls&#61;"http://openapi.baidu.com/oauth/2.0/token?grant_type&#61;client_credentials&client_id&#61;OEAG26OXULG3g3kHr9we3IFa&client_secret&#61;G9hCptqBbNj0LgqSkbNZVFfsVKHRbn3y"
Htmltxt&#61;Url.get(Urls,"gbk")
If CBool(InStr(1, Htmltxt, "{")) Then //小小BUG.谢谢1311,1693师弟纠正
talbeV &#61; Encode.JsonToTable(Htmltxt)
If talbeV <> "" Then
cuid&#61; zm.RndStr(10, 2)
PostData &#61; "tex&#61;" &zm.EncodeURL( txt )& "&lan&#61;zh&cuid&#61;" & cuid & "&ctp&#61;1&spd&#61;"&spd&"&&pit&#61;"&pit&"&per&#61;"&per&"&vol&#61;"&vol&"&tok&#61;" & talbeV["access_token"]
Url1&#61;"http://tsn.baidu.com/text2audio?"
zm.HttpDownload Url1 & PostData, Path
PlaySound Path
Delay sd
StopPlay
Dir.Delete( Path)
End If
End If
End Sub