访问如下地址即可返回对应的语音朗读文件:
http://tts.baidu.com/text2audio?cuid=baiduid&lan=zh&ctp=1&pdt=311&tex=土克西杨同学很帅
只需要将tex换成你需要朗读的文字即可。
不知道有没有调用限制,能用多久,临时用用还是可以的。
js调用代码如何:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <! DOCTYPE html> < html lang = "en" > < head > < meta charset = "UTF-8" > < title >Document</ title > </ head > < body > < form action = "" method = "post" > < table align = "center" > < tr > < td >< input type = "text" id = 'val' placeholder = '你要装换的文字' ></ td > < td >< input type = "button" value = "提交" ο nclick = "fun()" ></ td > </ tr > </ table > </ form > </ body > </ html > < script type = "text/javascript" > function fun() { var val=document.getElementById("val").value; var zhText = val; zhText = encodeURI(zhText); document.write("< audio autoplay=\"autoplay\">"); document.write("< source src=\"http://tts.baidu.com/text2audio? lan = zh & ie = UTF -8& spd = 2 & text = "+ zhText +" \" type=\"audio/mpeg\">"); document.write("< embed height=\"0\" width=\"0\" src=\"http://tts.baidu.com/text2audio? lan = zh & ie = UTF -8& spd = 2 & text = "+ zhText +" \">"); document.write("</ audio >"); } </ script > |
每日壁纸