PHP 将文字转化mp3文件
生活随笔
收集整理的這篇文章主要介紹了
PHP 将文字转化mp3文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
PHP代碼?
/*$target = '今天你上天了么'; $str = htmlspecialchars_decode($target); //str_replace("、",",",$target); //保留頓號 $strr = str_replace(" ", "", $str); // str_replace(' ','',$str); $strrr = strip_tags($strr); $text= str_replace(array(" ", " ", " "," ","‌","‍","“","”"), "", $strrr); // match_chinese($strr); // $news_detail['title']; //per=>聲音 //aue=>語速 $file = file_get_contents("http://tts.baidu.com/text2audio?cuid=baiduid&lan=zh&ctp=9&pdt=122&per=5003&aue=3&spd=3&tex=$text"); $filepath="1.mp3"; //寫入文件 @unlink($filepath); file_put_contents($filepath,$file);參數說明
html 和js
<script type="text/javascript"> function fun(){var myAuto = document.getElementById("myaudio");// myAuto.play();if (myAuto.paused) { //判斷音樂是否在播放中,暫停狀態myAuto.play(); //音樂播放 } else { //播放狀態myAuto.pause(); //音樂停止} } </script><div class="tit"><audio id="myaudio" preload="auto" src=".1.mp3" type="audio/mp3" controls="controls" autostart="false" hidden="true"></audio> </div>?
總結
以上是生活随笔為你收集整理的PHP 将文字转化mp3文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java方法区对象类型_浅谈Java内存
- 下一篇: php面向对象编程详解,PHP面向对象编