테스트 사이트 - 개발 중인 베타 버전입니다

네이버 클로버 tts

· 8년 전 · 5070 · 3
[code]
<?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;
}
[/code]

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 3개

1일 제한 1만자
방구석기타리스트
7년 전
감사합니다~!
혹시... 반대는 없나요?
아직 찾은게 없네요 ㅎㅎ

게시글 목록

번호 제목
15969
jQuery .jquery
15968
15967
jQuery .is()
15966
15965
15964
15963
15962
jQuery .index()
15961
15960
15959
jQuery .html()
15958
15957
jQuery .hide ()
15956
15955
15954
15953
15952
15949
15947
15946
15945
15944
15942
15941
15940
15939
15938
15937
15936