|
|
@ -7,31 +7,36 @@ error_reporting(-1);
|
|
|
|
ini_set("display_errors", "On");
|
|
|
|
ini_set("display_errors", "On");
|
|
|
|
// requires php5
|
|
|
|
// requires php5
|
|
|
|
define('UPLOAD_DIR', '../uploads/5/');
|
|
|
|
define('UPLOAD_DIR', '../uploads/5/');
|
|
|
|
|
|
|
|
define('DISTORT_DIR', 'python-audio-effects/');
|
|
|
|
$img = $_POST['base64'];
|
|
|
|
$img = $_POST['base64'];
|
|
|
|
$img = str_replace('data:audio/mp3;base64,', '', $img);
|
|
|
|
$img = str_replace('data:audio/mp3;base64,', '', $img);
|
|
|
|
$img = str_replace(' ', '+', $img);
|
|
|
|
$img = str_replace(' ', '+', $img);
|
|
|
|
$data = base64_decode($img);
|
|
|
|
$data = base64_decode($img);
|
|
|
|
#$file = UPLOAD_DIR . uniqid() . '.mp3';
|
|
|
|
#$file = UPLOAD_DIR . uniqid() . '.mp3';
|
|
|
|
$file = UPLOAD_DIR . $_POST['name'] . '_'.$_POST['type'] .'.mp3';
|
|
|
|
$file = UPLOAD_DIR . $_POST['name'] . '_'.$_POST['type'] .'.mp3';
|
|
|
|
|
|
|
|
// $file = DISTORT_DIR . $_POST['name'] . '_'.$_POST['type'] .'.mp3';
|
|
|
|
$success = file_put_contents($file, $data);
|
|
|
|
$success = file_put_contents($file, $data);
|
|
|
|
$distortedfile= $_POST['name'] . '_'.$_POST['type'] .'.wav';
|
|
|
|
$wavfile = $file.'.wav';
|
|
|
|
|
|
|
|
$distortedfile = $wavfile.'.wav';
|
|
|
|
|
|
|
|
|
|
|
|
// $command = escapeshellcmd('/home/lain/virtualenvs/radioactive/bin/python3 python-audio-effects/echo.py '.$file);
|
|
|
|
// $command = escapeshellcmd('/home/lain/virtualenvs/radioactive/bin/python3 python-audio-effects/echo.py '.$file);
|
|
|
|
// $output = shell_exec($command);
|
|
|
|
// $output = shell_exec($command);
|
|
|
|
// echo $output;
|
|
|
|
// echo $output;
|
|
|
|
|
|
|
|
|
|
|
|
// if type=echo "string";
|
|
|
|
// if type=echo "string";
|
|
|
|
shell_exec('ffmpeg -i python-audio-effects/try_echo.mp3 python-audio-effects/try_echo.wav');
|
|
|
|
shell_exec('ffmpeg -i "'.$file.'" "'.$wavfile.'"');
|
|
|
|
|
|
|
|
|
|
|
|
$command = '/home/lain/virtualenvs/radioactive/bin/python3 python-audio-effects/echo.py python-audio-effects/temp.wav';
|
|
|
|
|
|
|
|
|
|
|
|
$command = '/home/lain/virtualenvs/radioactive/bin/python3 python-audio-effects/echo.py "'.$wavfile.'" "'.$distortedfile.'"';
|
|
|
|
$output=shell_exec($command);
|
|
|
|
$output=shell_exec($command);
|
|
|
|
print $output;
|
|
|
|
print $output;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# make a database of recordings
|
|
|
|
# make a database of recordings
|
|
|
|
$item=array('name'=>$_POST['name'],'type'=>$_POST['type'],'date'=>date("d/m/Y"), 'file'=>$file);
|
|
|
|
$item=array('name'=>$_POST['name'],'type'=>$_POST['type'],'date'=>date("d/m/Y"), 'file'=>$distortedfile);
|
|
|
|
$handle=fopen('../uploads/5/index.jsons','a');
|
|
|
|
$handle=fopen('../uploads/5/index.jsons','a');
|
|
|
|
fwrite($handle,json_encode($item)."\n");
|
|
|
|
fwrite($handle,json_encode($item)."\n");
|
|
|
|
fclose($handle);
|
|
|
|
fclose($handle);
|
|
|
|
print $success ? $file : 'Unable to save the file.';
|
|
|
|
print $success ? $distortedfile : 'Unable to save the file.';
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|