slk 转码为wav后, 语音识别率非常低,要怎么解决
隐逆封尘 发布于2017-07 浏览:2278 回复:1
0
收藏
$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://vop.baidu.com/server_api?cuid=".$cuid."&token=".$token;
$url = $url."&lan=zh";
$audio = file_get_contents($fileUrl);
$content_len = "Content-Length: ".strlen($audio);
$header = array ($content_len,'Content-Type: audio/wav; rate=16000',);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, $audio);
$response = curl_exec($ch);
if(curl_errno($ch))
{
   print curl_error($ch);
}
curl_close($ch);
$response = json_decode($response, true);


收藏
点赞
0
个赞
共1条回复 最后由用户已被禁言回复于2022-04
#2fujiayi1984回复于2017-07

隐逆封尘:

$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://vop.baidu.com/server_api?cuid=".$cuid."&token=".$token;
$url = $url."&lan=zh";
$audio = file_get_contents($fileUrl);
$content_len = "Content-Length: ".strlen($audio);
$header = array ($content_len,'Content-Type: audio/wav; rate=16000',);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, $audio);
$response = curl_exec($ch);
if(curl_errno($ch))
{
   print curl_error($ch);
}
curl_close($ch);
$response = json_decode($response, true);


回复隐逆封尘:您如何判断识别率低是由转码造成的?

0
TOP
切换版块