Skip to main content

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

Project description

monkeyplug

Latest Version VOSK Docker Images Whisper Docker Images

monkeyplug is a little script to censor 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. Either Whisper (GitHub) or 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 or "bleeping" 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:

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, except for vosk or openai-whisper; as monkeyplug can work with both speech recognition engines, there is not a hard installation requirement for either until runtime.

usage

usage: monkeyplug.py <arguments>

monkeyplug.py

options:
  -v, --verbose [true|false]
                        Verbose/debug output
  -m, --mode <string>   Speech recognition engine (whisper|vosk) (default: whisper)
  -i, --input <string>  Input file (or URL)
  -o, --output <string>
                        Output file
  --output-json <string>
                        Output file to store transcript JSON
  -w, --swears <profanity file>
                        text file containing profanity (default: "swears.txt")
  -a, --audio-params APARAMS
                        Audio parameters for ffmpeg (default depends on output audio codec)
  -c, --channels <int>  Audio output channels (default: 2)
  -s, --sample-rate <int>
                        Audio output sample rate (default: 48000)
  -f, --format <string>
                        Output file format (default: inferred from extension of --output, or "MATCH")
  --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)
  -b, --beep [true|false]
                        Beep instead of silence
  -h, --beep-hertz <int>
                        Beep frequency hertz (default: 1000)
  --beep-mix-normalize [true|false]
                        Normalize mix of audio and beeps (default: False)
  --beep-audio-weight <int>
                        Mix weight for non-beeped audio (default: 1)
  --beep-sine-weight <int>
                        Mix weight for beep (default: 1)
  --beep-dropout-transition <int>
                        Dropout transition for beep (default: 0)
  --force [true|false]  Process file despite existence of embedded tag

VOSK Options:
  --vosk-model-dir <string>
                        VOSK model directory (default: ~/.cache/vosk)
  --vosk-read-frames-chunk <int>
                        WAV frame chunk (default: 8000)

Whisper Options:
  --whisper-model-dir <string>
                        Whisper model directory (~/.cache/whisper)
  --whisper-model-name <string>
                        Whisper model name (base.en)
  --torch-threads <int>
                        Number of threads used by torch for CPU inference (0)

Docker

Alternately, a Dockerfile is provided to allow you to run monkeyplug in Docker. You can pull one of the following images:

  • VOSK
    • oci.guero.org/monkeyplug:vosk-small
    • oci.guero.org/monkeyplug:vosk-large
  • Whisper
    • oci.guero.org/monkeyplug:whisper-tiny.en
    • oci.guero.org/monkeyplug:whisper-tiny
    • oci.guero.org/monkeyplug:whisper-base.en
    • oci.guero.org/monkeyplug:whisper-base
    • oci.guero.org/monkeyplug:whisper-small.en
    • oci.guero.org/monkeyplug:whisper-small
    • oci.guero.org/monkeyplug:whisper-medium.en
    • oci.guero.org/monkeyplug:whisper-medium
    • oci.guero.org/monkeyplug:whisper-large-v1
    • oci.guero.org/monkeyplug:whisper-large-v2
    • oci.guero.org/monkeyplug:whisper-large-v3
    • oci.guero.org/monkeyplug:whisper-large

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-2.1.6.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

monkeyplug-2.1.6-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: monkeyplug-2.1.6.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for monkeyplug-2.1.6.tar.gz
Algorithm Hash digest
SHA256 ebf6e1d476e92d098e71143603221ad236a82db827880f94d60dcac59850f687
MD5 5c37da18b4c74060646e3a159d30817e
BLAKE2b-256 0d29dcf26fd91a7ee55f47285d84f5053c3aa2ea95c9a0a22dcb42eae1b93e20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: monkeyplug-2.1.6-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for monkeyplug-2.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e03fdbf39e39442e0314db0c830f197bef6e56ba3768207d82b4942c569a3d3f
MD5 3d4af88d916691a66bbb8a87f8b9435b
BLAKE2b-256 db8299f70d13d68a3f9bbef3eaea2fbe58bc2804ea0a74fea7f24145bd13a2ab

See more details on using hashes here.

Supported by

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