当前位置:   article > 正文

百度语音接口,文字转语音接口

百度语音接口,文字转语音接口

<!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>

转载于:https://my.oschina.net/u/2336787/blog/1584550

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/961893
推荐阅读
相关标签
  

闽ICP备14008679号