ساخت ویس با هوش مصنوعی ( زبان فارسی )
<?php
header('Content-Type: application/json; charset=utf-8');
$text = $_GET['text'] ?? '';
$character = $_GET['character'] ?? 'woman';
$voices = [
'man' => 'wCpDE4gsR6807a59702179cfa9e078954784f43e70FKks86Ob_neural',
'woman' => 'shWiVtImn6807a59702179cfa9e078954784f43e7sY6wpUqA3_neural',
];
if (empty($text)) {
echo json_encode([
'status' => 'error',
'message' => 'Parameter "text" is required.'
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
exit;
}
if (!isset($voices[$character])) {
echo json_encode([
'status' => 'error',
'message' => 'Invalid character. Use "man" or "woman".'
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
exit;
}
$data = [
'csrf_test_name' => '39be94db037027744fb8cafd0d9fe321',
'front_tryme_language' => 'fa-IR',
'front_tryme_voice' => $voices[$character],
'front_tryme_text' => $text,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://texttospeech.online/home/tryme_action/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
'Cookie: csrf_cookie_name=39be94db037027744fb8cafd0d9fe321',
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo json_encode([
'status' => 'error',
'message' => 'Connection error: ' . curl_error($ch)
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
exit;
}
curl_close($ch);
$result = json_decode($response, true);
if (json_last_error() === JSON_ERROR_NONE) {
echo json_encode([
'status' => 'success',
'raw_response' => $result
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
} else {
echo json_encode([
'status' => 'error',
'message' => 'Invalid JSON response.',
'raw_response' => $response
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
با منبع بفرست چنلت ❤️
@PaMicK
@CristalTeam