Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/machow/scrampy

rearrange audio like it's no one's business.
https://github.com/machow/scrampy

Last synced: about 1 month ago
JSON representation

rearrange audio like it's no one's business.

Awesome Lists containing this project

README

        

scrampy
=======
Scrambling audio like it aint nobody's business.

Examples
--------
scrampy uses something called blueprints.
See "How it Works" for all the juicy details on how these work.

**Ipython Notebook Examples**

- [create a blueprint for interleaved audio](examples/example_create_interl_bp.ipynb)
- [generate audio from blueprint](examples/example_use_simple_bp.ipynb)

All examples below may be run from the shell (and untested on Windows :O).

### Scrambline and Unscrambling

Below, we use the blueprint found in `examples/simple/interl_blueprint.csv`:
name start end length order 0 NTF 0 8921 8921 0 1 pieman 14000 26970 12970 0 2 NTF 8921 19694 10773 1 3 pieman 26970 41620 14650 1

This blueprint interleaves two audio narratives, to generate the interleaved audio.
The narratives are in `aud/{narrative_folder}`.

cd examples
scrampy make-audio simple/interl_blueprint.csv \
"{pieman: aud/pieman/pieman.mp3, NTF: aud/NTF/NotTheFall.mp3}"

This produces interleaved audio as `default.wav` in the current directory.
Notice that there is a new blueprint titled `default.csv` produced as well.
This blueprint contains start and stop times with respect to the audio file just produced..
name start end length order old_name 0 default.wav 0 8921 8921 0 NTF 1 default.wav 8921 21891 12970 0 pieman 2 default.wav 21891 32664 10773 1 NTF 3 default.wav 32664 47314 14650 1 pieman

scrampy can use this to pull out segments corresponding to just one story.
For example, to align it with `aud/pieman/pieman_blueprint.csv`, which describes just one of the audio sources:
name order 0 pieman 0 1 pieman 1

to align, we would just do..

scrampy align default.csv aud/pieman/pieman_blueprint.csv

Note that all you need is name and order columns in the second file.
By default, the output is saved as aligned.csv, so we can use this file to reverse the process:

scrampy make-audio aligned.csv "{default.wav: default.wav}" \
--audout pieman.wav --bpout pieman_blueprint.csv

### Inserting gaps between each segment
Gaps can be inserted after each row using the `insert-gaps` command.
For example, if your current directory is `examples`

scrampy insert-gaps simple/interl_blueprint.csv # print new blueprint
scrampy insert-gaps simple/interl_blueprint.csv -o new_bp.csv # save as new_bp.csv

Now, we just need to specify where the gaps file is, in addition to other audio files.

scrampy make-audio new_bp.csv \
"{pieman: aud/pieman/pieman.mp3, NTF: aud/NTF/NotTheFall.mp3, gap: aud/silence.mp3}" \
--audout gaps.wav --bpout gaps.csv

Notice that when we generated audio from this blueprint, each segment+gap in `gaps.csv` ends on a 1500ms TR:
name start end length order old_name 0 gaps.wav 0 8921 8921 0 NTF 1 gaps.wav 8921 10500 1579 -1 gap 2 gaps.wav 10500 23470 12970 0 pieman 3 gaps.wav 23470 25500 2030 -1 gap 4 gaps.wav 25500 36273 10773 1 NTF 5 gaps.wav 36273 37500 1227 -1 gap 6 gaps.wav 37500 52150 14650 1 pieman 7 gaps.wav 52150 54000 1850 -1 gap

Order for gaps is set to -1 for all by default, since it doesn't really matter.

How it Works
------------
### Blueprints
scrampy uses spreadsheets saved in csv format to construct audio from different sources.
The spreadsheets are refered to as blueprints.
For example, the blueprint in `examples/simple/interl_blueprint.csv` looks like this:

name start end length order 0 NTF 0 8921 8921 0 1 pieman 14000 26970 12970 0 2 NTF 8921 19694 10773 1 3 pieman 26970 41620 14650 1

Here is what each column describes:

* name: name describing source of audio
* start, end: interval in milliseconds where segment is located in audio corresponding to {name}
* length: length of that segment in milliseconds
* order: order of segment with respect to source in name column

Basically, each segment should have a unique combination of **name** and **order** (unless it's being repeated).

### Creating blueprints
As long as it has the columns listed above, and uses milliseconds, it's a blueprint!
There is also a helper command, `parse-splits`, that can generate a basic blueprints
from a csv that just gives the name and break points--e.g.:

name break 0 NTF 0:00.000 1 NTF 0:08.921 2 NTF 0:19.694

Notice that here, **you can give breaks in either milliseconds or clock time**.

Help
----

`scrampy -h` shows possible commands

`scrampy {CMD_NAME}` shows help for a command (e.g. `scrampy align -h`)