Giter VIP home page Giter VIP logo

vian2020 / audero-wav-extractor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aurelioderosa/audero-wav-extractor

0.0 0.0 0.0 6.05 MB

Audero Wav Extractor is a PHP library that allows to extract a chunk from a wav file. The extracted chunk can be saved on the hard disk, can be forced to be prompted as download by the user's browser or returned as a string for a later processing.

JavaScript 52.98% PHP 37.10% CSS 9.92%

audero-wav-extractor's Introduction

Audero Wav Extractor

Audero Wav Extractor is a PHP library that allows to extract a chunk from a wav file. The extracted chunk can be saved on the hard disk, can be forced to be prompted as download by the user's browser or returned as a string for a later processing.

Requirements

This library requires PHP version 5.3 or higher.

Download

Download via Composer

You can obtain "Audero Wav Extractor" via Composer adding the following lines to your composer.json:

"require": {
    "audero/audero-wav-extractor": "2.0.*"
}

And then run the install command to resolve and download the dependencies:

php composer.phar install

Composer will install the library to your project's vendor/audero directory.

Download via Git

If you haven't or don't want to use Composer, you can download the library from its repository via Git running the following command:

git clone https://github.com/AurelioDeRosa/Audero-Wav-Extractor.git

Usage

"Audero Wav Extractor" is very easy to use. However, since the library uses namespaces and follows the PSR standards, you've to use an autoloader to dynamically load the classes needed. After that, you have to create an AuderoWavExtractor instance and call the method that better fits your needs. With Audero Wav Extractor you can download the chunk using downloadChunk(), save it on the hard disk using saveChunk() or retrieve it as a string using getChunk().

Installed via Composer

If you installed "Audero Wav Extractor" using Composer, you can rely on the built autoloader. So, after included the latter, you can use one of the previously cited methods as shown in the following example.

Extract a chunk from a wav file and force the download to the user's browser

<?php
    // Include the Composer autoloader
    require_once 'vendor/autoload.php';

    $inputFile = 'sample1.wav';
    $outputFile = '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();
    }
?>

Installed via Git

If you obtained the code via Git, you can use the autoloader provided by the library. However, before using it, you've to add the path to the library to the PHP include path as shown in the following example.

Extract a chunk from a wav file and save it into the local disk

<?php
    // Set include path
    set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/../src/');
    // Include the class loader
    require_once 'Audero\Loader\AutoLoader.php';
    // Set the classes' loader method
    spl_autoload_register('Audero\Loader\AutoLoader::autoload');

    $inputFile = 'sample1.wav';
    $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();
    }
?>

Resources

License

Audero Wav Extractor is licensed under the CC BY-NC 3.0 ("Creative Commons Attribution NonCommercial 3.0")

Authors

Aurelio De Rosa (Twitter: @AurelioDeRosa)

audero-wav-extractor's People

Contributors

aurelioderosa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.