接口地址
https://api.vvhan.com/api/song
返回格式
JSON
請求方式:
GET
請求示例:
https://api.vvhan.com/api/song?txt=內容
參數說明
| 名稱 | 必填 | 類型 | 說明 |
|---|---|---|---|
| txt | 是 | string | 輸入內容 |
| per | 否 | string | 男聲or女聲(1-6) |
返回數據
音頻直接輸出
調用實例
<video controls="" autoplay="" name="media"> <source src="https://api.vvhan.com/api/song.php?txt=需要轉換的內容" type="audio/mpeg"> </video>
示例代碼
<?php
if (isset($_GET['per'])) { $per = $_GET['per']; if ($per > 0 && $per < 7) { $per = $per; } } else { $per = 4; } if (isset($_GET['txt'])) { $txt = $_GET['txt']; header("Content-Type: audio/mpeg"); $voice = file_get_contents('https://api.vvhan.com/api/song?txt=' . $txt . ' &per=' . $per); exit($voice); } else { header(' Content-type:application/json;charset=UTF-8'); exit('{"code":-1,"msg":"參數不完整"}'); }
?>