我使用的服务是:语音合成 REST_API
调用的接口是:REST_API
参数设置情况: http://tsn.baidu.com/text2audio?tex=%25E5%258F%25B6%25E9%2597%25AE%25E6%259C%25A8%25E4%25BA%25BA%25E6%25A1%25A9%25E5%2592%258F%25E6%2598%25A5%25E6%258B%25B3%25EF%25BC%258C&lan=zh&cuid=00%253A0c%253A29%253A3b%253A59%253Af8&ctp=1&tok=*************************
开发平台和机型:linux-arm
SDK版本号:
代码或日志截图(上传截图能帮助您更快解决问题):
复现步骤、现象及其他描述:
tts_Get_Parse aa
tts_Get_Parse bb
tts_Get_Parse cc
tts_Get_Parse dd
* Hostname in DNS cache was stale, zapped
* name lookup timed out
* Couldn't resolve host 'tsn.baidu.com'
* Closing connection 1
tts_Get_Parse ee
curl_easy_perform error:6.
tts_Get_Parse 111111
tts_Get_Parse aa
tts_Get_Parse bb
tts_Get_Parse cc
tts_Get_Parse dd
* Hostname in DNS cache was stale, zapped
* name lookup timed out
* Couldn't resolve host 'tsn.baidu.com'
* Closing connection 1
tts_Get_Parse ee
curl_easy_perform error:6.
tts_Get_Parse 111111
//put your params here
$cuid = "";
$apiKey = "";
$secretKey = "";
$auth_url = "https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id=".$apiKey."&client_secret=".$secretKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $auth_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$response = curl_exec($ch);
if(curl_errno($ch))
{
print curl_error($ch);
}
curl_close($ch);
$response = json_decode($response, true);
$token = $response['access_token'];
$url = "http://tsn.baidu.com/text2audio?";
$param = "tex=123&lan=zh&ctp=1&cuid=".urlencode(urlencode($cuid))."&tok=".urlencode(urlencode($token));
$url = $url.$param;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
if(curl_errno($ch))
{
print curl_error($ch);
}
curl_close($ch);
var_dump($response);
file_put_contents("2.mp3", $response, FILE_APPEND);
?>