Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once "/srv/www/user4645/data/www/werwolf.ttandora.24x7s.com/bot/bd/nastr.php";
- include "/srv/www/user4645/data/www/werwolf.ttandora.24x7s.com/bot/obrabotka_zaprozow/taken.php";
- $para = array('peer_id' => "{$peer_id}",'type' => 'audio_message','access_token' => $token,'v' => $v);
- $para2 = http_build_query($para);
- $res = json_decode(file_get_contents(
- "https://api.vk.com/method/docs.getMessagesUploadServer?" . $para2));
- $res1 = $res->response->upload_url;
- $result = curl(
- 'https://tts.api.cloud.yandex.net/speech/v1/tts:synthesize',
- ['Authorization: Bearer '.$iam_token, 'Transfer-Encoding: chunked'],
- 'voice='.$golos.'&emotion='.$emotion2.'&format=oggopus&folderId='.$folder_id.'&text='.urlencode($text4));
- global $result;
- function curl($url, $headers = null, $post = null)
- {if ($ch1 = curl_init())
- {curl_setopt($ch1, CURLOPT_URL, $url);
- curl_setopt($ch1, CURLOPT_HEADER, false);
- curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
- if (! empty($headers))
- {curl_setopt($ch1, CURLOPT_HTTPHEADER, $headers);}
- if (! empty($post))
- {curl_setopt($ch1, CURLOPT_POST, true);
- curl_setopt($ch1, CURLOPT_POSTFIELDS, $post);}
- $result = curl_exec($ch1);
- curl_close($ch1);
- return $result;}
- return false;}
- $im = rand(1, 2000).'.ogg';
- file_put_contents($im, $result); //сохраняю
- $file = __DIR__ ."/../$im";
- $file = curl_file_create($file, mime_content_type($file), pathinfo($file)['basename']);
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $res1);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: multipart/form-data'));
- curl_setopt($curl, CURLOPT_POSTFIELDS, ['file' => $file]);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_TIMEOUT, 1500);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
- $six = json_decode(curl_exec($curl));
- $sax = $six->file;
- $pam = http_build_query(array(
- 'file' => $sax,
- 'access_token' => $token,
- 'v' => $v));
- $sexi = json_decode(file_get_contents(
- "https://api.vk.com/method/docs.save?" . $pam), true);
- $owner_id = $sexi["response"]["audio_message"]["owner_id"];
- $id = $sexi["response"]["audio_message"]["id"];
- $fhoto_i = "audio_message{$owner_id}_{$id}";
- $request_params = array('attachment' => $fhoto_i,'random_id' => "{$kod2}",'peer_id' => $peer_id,'access_token' => $token,'v' => $v);
- $get_params = http_build_query($request_params);
- file_get_contents('https://api.vk.com/method/messages.send?'. $get_params);
- unlink("/srv/www/user4645/data/www/werwolf.ttandora.24x7s.com/bot/$im");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement