case 7:
                $upload_error = "Failed to write file to disk.";
            case 8:
                $upload_error = "A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help.";
            default:
                $upload_error = "unknown upload error";
        }
    }
    echo "Upload Error: " . $upload_error . "<br>";
    //die
    die;
}
//get path for original mp3file
$path = $upload_dir . '/' . $current_file_dir . ".mp3";
//read MP3
$mp3 = new mp3($path);
//create m3u8 header
$m3u8_file = "#EXTM3U \n#EXT-X-MEDIA-SEQUENCE:0 \n#EXT-X-TARGETDURATION:" . $partlenght . "\n";
//start on second 0
$position = 0;
//continue the loop while $continue_mp3split_loop = 1
$continue_mp3split_loop = 1;
while ($continue_mp3split_loop == 1) {
    //split the part
    $mp3_1 = $mp3->extract($position, $partlenght);
    //export and save the part as file
    $mp3_1->save($archive_path . "/" . $current_file_dir . '/' . 'file' . $position . '.mp3');
    //check if title has ended
    if (filesize($archive_path . "/" . $current_file_dir . '/' . 'file' . $position . '.mp3') < 2) {
        //stop the loop
        $continue_mp3split_loop = 0;
Exemplo n.º 2
0
$oDbc = new konexion("Web");
$debug->add("oDbc: " . var_export($oDbc, TRUE));
$DEBUG_LVL = 2;
$todo = count($ids);
$USE_LOCAL_FTP === TRUE ? $debug->add("Using Local FTP - 241") : $debug->add("Using Remote FTP - USA");
$debug->add("Preparing to process {$todo} contents...");
// borro work_dir
$debug->add("Cleaning working dir {$work_dir}...");
exec("rm -rf {$work_dir}/*");
$i = 0;
$j = 0;
foreach ($ids as $id) {
    $i++;
    $debug->add("******* Processing content #{$id}, {$i} of {$todo}...");
    $map = $xml_map["mp3_tpl"];
    $wp = new mp3($oDbc, $id);
    $wp->load($workingCat, $workingSubCat);
    // copio archivos
    $debug->add("## Copying mp3 sources...");
    $download_ok = FALSE;
    $file = $wp->icons;
    $debug->add("Downloading {$file}...to " . "{$work_dir}/" . $wp->filename . ".mp3");
    if (get_preview($file, "{$work_dir}/" . $wp->filename . ".mp3") === TRUE) {
        $debug->add("Download OK!");
        $download_ok = TRUE;
    } else {
        $debug->add("Download ERROR!!!");
    }
    if ($download_ok === TRUE) {
        $debug->add("Success!!! " . $wp->filename . ".mp3");
        $wp->add("objects", "<file>" . $wp->filename . ".mp3</file>\n");
Exemplo n.º 3
0
/**
 * Mathieu
 * Génère la synthèse vocale via google
 * Ou la récupère depuis notre cache si elle y est déjà
 * http://translate.google.com/translate_tts?ie=utf-8&tl=fr&q=...
 * @param string $text
 * @return string $mp3Path
 */
function getSpeechFromString($text)
{
    $text = html_entity_decode(strip_tags($text));
    $sansAccent = array("idee", "demarches", "ecouter", "ecrire");
    $avecAccent = array("idée", "démarche", "écouter", "écrire");
    $text = str_ireplace($sansAccent, $avecAccent, $text);
    $key = sha1($text);
    $mp3Path = "cacheTextToSpeech" . DIRECTORY_SEPARATOR . $key . ".mp3";
    // si une seule requete google
    if (strlen($text) <= 100) {
        if (!file_exists($mp3Path)) {
            $url = "http://translate.google.com/translate_tts?ie=utf-8&tl=fr&q=" . urlencode($text);
            $mp3data = file_get_contents($url);
            file_put_contents($mp3Path, $mp3data);
        }
    } else {
        // génération de la liste des mp3
        $mp3Parts = array();
        $i = 0;
        do {
            $i++;
            $textPart = smartSplitText($text, 100);
            $keyPart = sha1($textPart);
            $mp3Parts[$keyPart] = getSpeechFromString($textPart);
            $text = substr($text, strlen($textPart), strlen($text) - strlen($textPart));
        } while (trim($text) != "" && $i < 10);
        // assemblage de la liste des MP3
        $mp3 = new mp3();
        foreach ($mp3Parts as $keyPart => $mp3Part) {
            $mp3->mergeBehind(new mp3($mp3Part));
        }
        file_put_contents($mp3Path, $mp3->str);
    }
    return $mp3Path;
}
 function multiJoin($newpath, $array)
 {
     foreach ($array as $path) {
         $mp3 = new mp3($path);
         $mp3->striptags();
         $mp3_1 = new mp3($newpath);
         $mp3->mergeBehind($mp3_1);
         $mp3->save($newpath);
     }
 }