dub-script
Easily dub audio files using a simple command script.
Usage
The example below mixes a voice file from a remote source with a background song.
import dubscript as ds
segment = ds.process({
"version": "3",
"audio": [{
"type": "overlay",
"audio": [
{
"name": "voice",
"start": 500,
"audio": [
{"type": "file", "src": "https://mysite.com/1.wav"},
{"type": "silence", "duration": 1000},
{"type": "file", "src": "https://mysite.com/2.wav"},
]
},
{
"name": "song",
"audio": [
{"type": "file", "src": "local/dir/bg.mp3", "gain": -10}
]
}
]
}]
})
segment.export('podcast.mp3')
Dependencies
dub-script is powered by Pydub and inherits its dependencies. Install ffmpeg or libav if you need to manipulate non-wave files, like mp3.
Installation
python setup.py install
Why?
This lib was originally intended to generate a podcast from a few audio files. You can use Pydub for this, but the idea of having a JSON recipe for it has several advantages. Having a recipe means you can version it and keep track of changes. Also, you can easily create a REST API that generates audios using dub-script. Finally, I find it easier to understand the audio processing when only looking at the JSON.
Commands
With dub-script, everything is done through commands that follow this basic structure:
{
"type": "<command_type>"
}
The only exception is the concat command, which doesn't have a type:
{
"audio": [
// audios to concatenate here
]
}
Load local or remote files
Use file to load audio data.
{
"type": "file",
// you can have either an url or a path
"src": "<local or remote source>"
}
Add silence
Use silence to add a silent bit in milliseconds.
{
"type": "silence",
"duration": 1000
}
Concatenate
Join audio together with concatenate:
{
"audio": [
{ "type": "file1.wav" },
{ "type": "file2.wav" }
// ...
]
}
Overlay
Mix audio tracks that plays at the same time with overlay.
Note: the length of the overlaid audio will always be equal to the first audio in the series.
{
"type": "overlay",
"audio": [
// holds the tracks
{
"name": "track1", // track names are not required and are only here for organization purposes (yet)
"start": 3000, // this track will be delayed by 3 seconds
"audio": [{ "type": "file1.wav" }, { "type": "file2.wav" }]
},
{
"audio": [{ "type": "file3.wav" }],
"gain": 5 // the previous track will be boosted by +5 db while they overlap
}
]
}
Filters
Filters can be applied to any other command.
Change volume
You can change the volume with gain. For instance:
{
"type": "file",
"src": "quiet.wav",
"gain": 3
}
Fade In/Out
Fade audio with either fade_in or fade_out:
{
"audio": [
{
"type": "file",
"src": "intro.mp3",
"fade_in": 3000 // fade the first 3 seconds
},
{
"type": "file",
"src": "main.mp3",
"fade_out": 10000 // fade the last 10 seconds
}
]
}
License
Licensed under the MIT License.
Metadata
Release files for dubscript 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dubscript-0.1-py3-none-any.whl | Python 3 | none | any | Details for dubscript-0.1-py3-none-any.whl |
Release files / dubscript-0.1-py3-none-any.whl
| Download URL | dubscript-0.1-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9cbb4b2ac3c6f620295bf284e40f79e09082fa37aae01d11b6bb4626dfa50d23
|
|
BLAKE2b-256 checksum How to use checksums |
e46ce6ad03f0fad911debd24bdc70fdfa34136c771f2dcfe3b0fae6b07280cbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Security for dubscript 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.