<?php
$client_id = "";
$client_secret = "";
$txt = $_GET['txt'];
if(!$txt) $txt = '텍스트 파라미터를 입력 바랍니다.';
$encText = urlencode($txt);
$postvars = "speaker=mijin&speed=0&text=".$encText;
$url = "https://openapi.naver.com/v1/voice/tts.bin";
$is_post = true;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, $is_post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $postvars);
$headers = array();
$headers[] = "X-Naver-Client-Id: ".$client_id;
$headers[] = "X-Naver-Client-Secret: ".$client_secret;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec ($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
if($status_code == 200) {
header("Content-type: audio/mpeg");
header("Content-Transfer-Encoding: binary");
header('Pragma: no-cache');
header('Expires: 0');
echo $response;
} else {
echo "Error 내용:".$response;
}
문제는 1일 1만자 입니다.
Trackback Address :: 이 글에는 트랙백을 보낼 수 없습니다