나는 mp4 비디오 클립을 FLAC 오디오 파일로 변환하려고 시도하고 있으며, 다음과 같이 검색 할 수 있도록 동영상에서 단어를 뱉어 내고 있습니다. 특정 단어는 말했다. 나는 FLAC 파일로 MP4로 변환하기 위해 FFMPEG를 사용하고Google Speech API "요청시 샘플링 속도가 FLAC 헤더와 일치하지 않습니다."
{
"error": {
"code": 400,
"message": "Sample rate in request does not match FLAC header.",
"status": "INVALID_ARGUMENT"
}
}
:
나는 모든 것을 나는 음성 API에서 오류를 얻고 것을 제외하고 작업을해야합니다. FLAC 파일을 명령에서 16 비트로 지정했지만 FLAC 파일을 마우스 오른쪽 버튼으로 클릭하면 Windows에서 302kbps라고 알려줍니다.
// convert mp4 video to 16 bit flac audio file
$cmd = 'C:/wamp/www/ffmpeg/bin/ffmpeg.exe -i C:/wamp/www/test.mp4 -c:a flac -sample_fmt s16 C:/wamp/www/test.flac';
exec($cmd, $output);
// convert flac to text so we can detect if certain words were said
$data = array(
"config" => array(
"encoding" => "FLAC",
"sampleRate" => 16000,
"languageCode" => "en-US"
),
"audio" => array(
"content" => base64_encode(file_get_contents("test.flac")),
)
);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://speech.googleapis.com/v1beta1/speech:syncrecognize?key=MY_API_KEY');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
샘플 형식 (부호가 16으로 설정 됨)과 샘플 속도간에 차이가 있습니다. – fakedad
감사합니다. 알아 냈습니다. Google Speech API는 비트, 샘플 및 채널과 함께 매우 까다 롭습니다. – kjdion84