monkeyplug is a little script to mute profanity in audio files.
Project description
monkeyplug
monkeyplug is a little script to mute profanity in audio files (intended for podcasts, but YMMV) in a few simple steps:
- The user provides a local audio file (or a URL pointing to an audio file which is downloaded)
- The Vosk-API is used to recognize speech in the audio file
- Each recognized word is checked against a list of profanity or other words you'd like muted
ffmpeg
is used to create a cleaned audio file, muting the objectional words
You can then use your favorite media player to play the cleaned audio file.
If provided a video file for input, monkeyplug will attempt to process the audio stream from the file and remultiplex it, copying the original video stream.
monkeyplug is part of a family of projects with similar goals:
- 📼 cleanvid for video files
- 🎤 monkeyplug for audio files
- 📕 montag for ebooks
Installation
Using pip
, to install the latest release from PyPI:
python3 -m pip install -U monkeyplug
Or to install directly from GitHub:
python3 -m pip install -U 'git+https://github.com/mmguero/monkeyplug'
Prerequisites
monkeyplug requires:
- A Vosk-API compatible model in a subdirectory named
model
in the same directory asmonkeyplug.py
, or in a custom directory location indicated with the--model
runtime option or theVOSK_MODEL
environment variable
To install FFmpeg, use your operating system's package manager or install binaries from ffmpeg.org. The Python dependencies will be installed automatically if you are using pip
to install monkeyplug.
usage
usage: monkeyplug.py <arguments>
monkeyplug.py
options:
-v [true|false], --verbose [true|false]
Verbose/debug output
-i <string>, --input <string>
Input file (or URL)
-o <string>, --output <string>
Output file
--output-json <string>
Output file to store JSON generated by VOSK
-w <profanity file>, --swears <profanity file>
text file containing profanity (default: "swears.txt")
-a APARAMS, --audio-params APARAMS
Audio parameters for ffmpeg (default depends on output audio codec")
-f <string>, --format <string>
Output file format (default: inferred from extension of --output, or "MATCH")
-m <string>, --model <string>
Vosk model path (default: "model")
--frames <int> WAV frame chunk (default: 8000)
--pad-milliseconds <int>
Milliseconds to pad on either side of muted segments (default: 0)
--pad-milliseconds-pre <int>
Milliseconds to pad before muted segments (default: 0)
--pad-milliseconds-post <int>
Milliseconds to pad after muted segments (default: 0)
--force [true|false] Process file despite existence of embedded tag
Docker
Alternately, a Dockerfile is provided to allow you to run monkeyplug in Docker. You can pull either the ghcr.io/mmguero/monkeyplug:small
or ghcr.io/mmguero/monkeyplug:large
Docker images, or build with build_docker.sh
, then run monkeyplug-docker.sh
inside the directory where your audio files are located.
Contributing
If you'd like to help improve monkeyplug, pull requests will be welcomed!
Authors
- Seth Grover - Initial work - mmguero
License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file monkeyplug-1.3.1.tar.gz
.
File metadata
- Download URL: monkeyplug-1.3.1.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5490f01718c34cd89549ba0e787b7bccb432f5bdd5528b461b35f24892bb565 |
|
MD5 | 02d6db3e43af43fc0f18768085189b1f |
|
BLAKE2b-256 | ae25ad214e6c8f8971e5a4d68e9b620df7be1f3b67951cfb0bba69af6e8a24bc |
File details
Details for the file monkeyplug-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: monkeyplug-1.3.1-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7726e0214966a877e1b728695a48b992b539bc52bdba9642cd5491dda0416af |
|
MD5 | e4e84a2cf61d66fdf0fde521359e5ea4 |
|
BLAKE2b-256 | db9de5fd043297f5d6a50ae25c441cf311e8b84d913ac7f427c1d7e12ffcbdec |