Public Repository

Last pushed: 2 years ago
Short Description
Audio Concatenator allows concatenate several `mp3` files into one.
Full Description

Audio Concatenator

Audio Concatenator allows concatenate several mp3 files into one.

Originally used for concatenate voice confirmation code files for VoxImplant-based solution.

Usage

Put your mp3 files in data directory, install dependencies and run server (just sinatra app).

After it you could send requests to perform concatenation of several files into one like this:

docker run -p 4567:4567 drakmail/audio_concatenator
wget http://127.0.0.1:4567/concatenate/hello,5,4,3,2.mp3

hello is a intro mp3 file, optionally.
5,4,3,2 is a mp3 files from data directory to concatenate.

After it application will take files hello.mp3, 5.mp3, 4.mp3, 3.mp3, 2.mp3 from data directory and return concatenated file 5,4,3,2.mp3 (which also will be cached in public/cache directory)

VoxImplant Script

var instructorCall, phone, code;

VoxEngine.addEventListener(AppEvents.Started, handleScenarioStart);

// get mp3 file url for confirmation code
function getMP3File(code) {
  var parsedCode = code.toString().split("").join(",");
  return "http://YOUR_HOST_NAME:4567/concatenate/hello," + parsedCode + ".mp3";
}

function handleScenarioStart(e) {
  // Data can be passed to scenario using customData
  // script_custom_data param in StartScenarios HTTP request will be available to scenario as customData
  // in this scenario we will pass number1:name string via script_custom_data, which contains
  // instructor phone number, message
  var data = VoxEngine.customData().split(":");
  // phone number of instructor
  phone = data[0];
  // confirmation code
  code = data[1];
  // start scenario - calling instructor number
  instructorCall = VoxEngine.callPSTN(phone);
  // instructor answers
  instructorCall.addEventListener(CallEvents.Connected, handleInstructorConnected);
  // couldn't call to instructor
  instructorCall.addEventListener(CallEvents.Failed, function(e) {
    VoxEngine.terminate();
  });
  // operator hang off
  instructorCall.addEventListener(CallEvents.Disconnected, function(e) {
    VoxEngine.terminate();
  });
}

function playFile(url) {
  // start playing mp3
  instructorCall.startPlayback(url, false);
  instructorCall.addEventListener(CallEvents.PlaybackFinished, function() {
    VoxEngine.terminate();
  });
}

function handleInstructorConnected(e) {
  // first call connected successfully, play message
  var url = getMP3File(code);
  playFile(url);
}

License

The MIT License

Copyright (c) 2016 Alexander Maslov http://drakmail.ru/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Docker Pull Command
Owner
drakmail

Comments (0)