Skip to main content

monkeyplug is a little script to mute profanity in audio files.

Project description

monkeyplug

Latest Version Docker Image

monkeyplug is a little script to mute profanity in audio files (intended for podcasts, but YMMV) in a few simple steps:

  1. The user provides a local audio file (or a URL pointing to an audio file which is downloaded)
  2. The Vosk-API is used to recognize speech in the audio file
  3. Each recognized word is checked against a list of profanity or other words you'd like muted
  4. 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:

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 as monkeyplug.py, or in a custom directory location indicated with the --model runtime option or the VOSK_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monkeyplug-1.3.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

monkeyplug-1.3.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file monkeyplug-1.3.0.tar.gz.

File metadata

  • Download URL: monkeyplug-1.3.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for monkeyplug-1.3.0.tar.gz
Algorithm Hash digest
SHA256 d39b44e0424f710bbea212ec3e2f7562d378af071c7f7df9a0f0e7580908719b
MD5 d604e96f35eeaf51a4a43c1bf4975ca2
BLAKE2b-256 807ec7bfb68dbbdedc420126b686bdc2beff6e75aa243bfc2a47a38dcac2f48c

See more details on using hashes here.

File details

Details for the file monkeyplug-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: monkeyplug-1.3.0-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

Hashes for monkeyplug-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c24b449a1fd6f720a8341b20b777fe558029698446af75e5ebf37a820a706a82
MD5 47794a4ba2006ad731dadb712ad841b9
BLAKE2b-256 165067b101b9234109f37253e51ffc8ad0f0498b8db9872c8d5dd290e118b5c1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page