PHP code example of audero / audero-wav-extractor

1. Go to this page and download the library: Download audero/audero-wav-extractor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

audero / audero-wav-extractor example snippets


        // Include the Composer autoloader
        utFile = 'chunk.wav';
        $start = 0 * 1000; // From 0 seconds
        $end = 2 * 1000; // To 2 seconds

        // Extract the chunk and save it on the hard disk
        try {
           $extractor = new \Audero\WavExtractor\AuderoWavExtractor($inputFile);
           $extractor->downloadChunk($start, $end, $outputFile);
           echo 'Chunk extraction completed.';
        } catch (\Exception $ex) {
           echo 'An error has occurred: ' . $ex->getMessage();
        }
    

        // Set include path
        set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/../src/');
        // Include the class loader
        outputFile = 'chunk.wav';
        $start = 0 * 1000; // From 0 seconds
        $end = 2 * 1000; // To 2 seconds

        // Extract the chunk and force the download to the user browser
        try {
           $extractor = new \Audero\WavExtractor\AuderoWavExtractor($inputFile);
           $extractor->saveChunk($start, $end, $outputFile);
           echo 'Chunk extraction completed.';
        } catch (\Exception $ex) {
           echo 'An error has occurred: ' . $ex->getMessage();
        }