一个免费的百度文字转语音接口。
- 接口链接
http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=2&text=待转换的文字
参数:
lan=zh:语言是中文,如果改为lan=en,则语言是英文。
ie=UTF-8:文字格式。
spd=2:语速,可以是1-9的数字,数字越大,语速越快。
text=**:这个就是你要转换的文字。
- 使用方法
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 
 | <!doctype html><html lang="en">
 <head>
 <meta charset="UTF-8">
 <title>Hello, world!</title>
 </head>
 <body>
 
 <textarea type="text" id='val' placeholder='请输入文字'></textarea>
 <input type="button" value="提交" onclick="clickEvent()" />
 
 <script type="text/javascript">
 window.onload = function () {
 }
 function clickEvent() {
 var zhText = document.getElementById("val").value;;
 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>
 </body>
 </html>
 
 | 
                
                
                
                
                
                    
                        
                        赞赏一下  坚持原创技术分享,您的支持将鼓励我继续创作!