把文字转成音频播放 [接口正常] 累计调用:102195
接口地址: https://api.linhun.vip/api/song
返回格式: JSON
请求方式: GET/POST
请求示例: https://api.linhun.vip/api/song?&per=0&pit=5&vol=9&spd=5&tex=内容&apiKey=获取临时密钥
开源地址: https://api.linhun.vip/pay/song.html
注意:请求示例中 参数第一个是 问号 例如 《?》,其他参数都是《&》,请求示例 对比 请求参数说明,或对比其他接口 来使用,apiKey在右上角后台进去生成,请求参数说明:
名称 | 必填 | 类型 | 说明 |
---|---|---|---|
tex | 是 | String | 转换的文字 |
per | 是 | String | 发音人(0-6) 默认0 |
spd | 是 | string | 语速 |
vol | 是 | string | 音量 |
pit | 是 | string | 音调 |
返回参数说明:
名称 | 类型 | 说明 |
---|
返回示例:
音频直接输出
错误码格式说明:
名称 | 类型 | 说明 |
---|
代码示例:
<?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.linhun.vip/api/song?txt='.$txt.'&per='.$per);
exit($voice);
}else{
header('Content-type:application/json;charset=UTF-8');
exit('{"code":-1,"msg":"参数不完整"}');
}
?>