Skip to main content

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

Project description

monkeyplug

Latest Version VOSK Docker Images Whisper Docker Images

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. 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 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 [true|false], --verbose [true|false]
                        Verbose/debug output
  -m <string>, --mode <string>
                        Speech recognition engine (whisper|vosk) (default: whisper)
  -i <string>, --input <string>
                        Input file (or URL)
  -o <string>, --output <string>
                        Output file
  --output-json <string>
                        Output file to store transcript JSON
  -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)
  -c <int>, --channels <int>
                        Audio output channels (default: 2)
  -f <string>, --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)
  --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)

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.top/monkeyplug:vosk-small
    • oci.guero.top/monkeyplug:vosk-large
  • Whisper
    • oci.guero.top/monkeyplug:whisper-tiny.en
    • oci.guero.top/monkeyplug:whisper-tiny
    • oci.guero.top/monkeyplug:whisper-base.en
    • oci.guero.top/monkeyplug:whisper-base
    • oci.guero.top/monkeyplug:whisper-small.en
    • oci.guero.top/monkeyplug:whisper-small
    • oci.guero.top/monkeyplug:whisper-medium.en
    • oci.guero.top/monkeyplug:whisper-medium
    • oci.guero.top/monkeyplug:whisper-large-v1
    • oci.guero.top/monkeyplug:whisper-large-v2
    • oci.guero.top/monkeyplug:whisper-large-v3
    • oci.guero.top/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.0.1.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

monkeyplug-2.0.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: monkeyplug-2.0.1.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for monkeyplug-2.0.1.tar.gz
Algorithm Hash digest
SHA256 d4974bb0507aeaec1871db93c641c69250315562905d172354b4452453d8a874
MD5 a8a968cba2057fccee31076e666a1cf7
BLAKE2b-256 b0f2ad236b895e0f3ecd3dcaca933eafb5015c1305867397a8f33aaa9ffc3686

See more details on using hashes here.

File details

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

File metadata

  • Download URL: monkeyplug-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for monkeyplug-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b73eea658f8810e84e5c1085efb4a6ca814e1574afaf5ce870163f059bfacc55
MD5 77a14859bea872c44d7f22ffac7d736e
BLAKE2b-256 666842b1109c529c12e8022c4a8bcb174cb92bf17ced370a56c7ca33fcdfaa99

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