monkeyplug-enhanced 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,142 @@
1
+ *.wav
2
+ *.mp3
3
+ *.ogg
4
+ *.flac
5
+ *.m4a
6
+ *.m4b
7
+ *.mp4
8
+ *.wma
9
+ *.aac
10
+
11
+ # Byte-compiled / optimized / DLL files
12
+ __pycache__/
13
+ *.py[cod]
14
+ *$py.class
15
+
16
+ # C extensions
17
+ *.so
18
+
19
+ # Distribution / packaging
20
+ .Python
21
+ build/
22
+ develop-eggs/
23
+ dist/
24
+ downloads/
25
+ eggs/
26
+ .eggs/
27
+ lib/
28
+ lib64/
29
+ parts/
30
+ sdist/
31
+ var/
32
+ wheels/
33
+ pip-wheel-metadata/
34
+ share/python-wheels/
35
+ *.egg-info/
36
+ .installed.cfg
37
+ *.egg
38
+ MANIFEST
39
+
40
+ # PyInstaller
41
+ # Usually these files are written by a python script from a template
42
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
43
+ *.manifest
44
+ *.spec
45
+
46
+ # Installer logs
47
+ pip-log.txt
48
+ pip-delete-this-directory.txt
49
+
50
+ # Unit test / coverage reports
51
+ htmlcov/
52
+ .tox/
53
+ .nox/
54
+ .coverage
55
+ .coverage.*
56
+ .cache
57
+ nosetests.xml
58
+ coverage.xml
59
+ *.cover
60
+ *.py,cover
61
+ .hypothesis/
62
+ .pytest_cache/
63
+
64
+ # Translations
65
+ *.mo
66
+ *.pot
67
+
68
+ # Django stuff:
69
+ *.log
70
+ local_settings.py
71
+ db.sqlite3
72
+ db.sqlite3-journal
73
+
74
+ # Flask stuff:
75
+ instance/
76
+ .webassets-cache
77
+
78
+ # Scrapy stuff:
79
+ .scrapy
80
+
81
+ # Sphinx documentation
82
+ docs/_build/
83
+
84
+ # PyBuilder
85
+ target/
86
+
87
+ # Jupyter Notebook
88
+ .ipynb_checkpoints
89
+
90
+ # IPython
91
+ profile_default/
92
+ ipython_config.py
93
+
94
+ # pyenv
95
+ .python-version
96
+
97
+ # pipenv
98
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
99
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
100
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
101
+ # install all needed dependencies.
102
+ #Pipfile.lock
103
+
104
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
105
+ __pypackages__/
106
+
107
+ # Celery stuff
108
+ celerybeat-schedule
109
+ celerybeat.pid
110
+
111
+ # SageMath parsed files
112
+ *.sage.py
113
+
114
+ # Environments
115
+ .env
116
+ .venv
117
+ env/
118
+ venv/
119
+ ENV/
120
+ env.bak/
121
+ venv.bak/
122
+
123
+ # Spyder project settings
124
+ .spyderproject
125
+ .spyproject
126
+
127
+ # Rope project settings
128
+ .ropeproject
129
+
130
+ # mkdocs documentation
131
+ /site
132
+
133
+ # mypy
134
+ .mypy_cache/
135
+ .dmypy.json
136
+ dmypy.json
137
+
138
+ # Pyre type checker
139
+ .pyre/
140
+
141
+ # Groq API key files
142
+ .groq_key
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2021, SG
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,360 @@
1
+ Metadata-Version: 2.4
2
+ Name: monkeyplug-enhanced
3
+ Version: 2.2.0
4
+ Summary: Enhanced fork of monkeyplug — censors profanity in audio files using speech recognition with Groq API, AI instrumental generation, and batch processing.
5
+ Project-URL: Homepage, https://github.com/ljbred08/monkeyplug
6
+ Project-URL: Issues, https://github.com/ljbred08/monkeyplug/issues
7
+ Project-URL: Repository, https://github.com/ljbred08/monkeyplug.git
8
+ Author-email: Seth Grover <mero.mero.guero@gmail.com>, Lincoln Brown <link@brown.fm>
9
+ License-File: LICENSE
10
+ Classifier: License :: OSI Approved :: BSD License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
14
+ Requires-Python: >=3.6
15
+ Requires-Dist: groq>=0.1.0
16
+ Requires-Dist: mmguero==2.0.3
17
+ Requires-Dist: mutagen==1.47.0
18
+ Requires-Dist: numpy>=1.24.0
19
+ Requires-Dist: requests==2.32.5
20
+ Requires-Dist: sherpa-onnx>=1.10.0
21
+ Requires-Dist: soundfile>=0.12.0
22
+ Description-Content-Type: text/markdown
23
+
24
+ # monkeyplug-enhanced
25
+
26
+ [![Latest Version](https://img.shields.io/pypi/v/monkeyplug-enhanced)](https://pypi.python.org/pypi/monkeyplug-enhanced/) [![VOSK Docker Images](https://github.com/mmguero/monkeyplug/workflows/monkeyplug-build-push-vosk-ghcr/badge.svg)](https://github.com/mmguero/monkeyplug/pkgs/container/monkeyplug) [![Whisper Docker Images](https://github.com/mmguero/monkeyplug/workflows/monkeyplug-build-push-whisper-ghcr/badge.svg)](https://github.com/mmguero/monkeyplug/pkgs/container/monkeyplug)
27
+
28
+ **monkeyplug-enhanced** is an enhanced fork of [mmguero/monkeyplug](https://github.com/mmguero/monkeyplug) (available on PyPI as `monkeyplug`). It censors profanity in audio files using speech recognition, detecting profanity timestamps and either muting, beeping, or splicing in instrumental audio using FFmpeg.
29
+
30
+ The CLI command is still `monkeyplug` — only the package name changed to avoid conflicting with the original.
31
+
32
+ ### Enhancements over the original
33
+
34
+ - **Groq API** integration (fast, default mode)
35
+ - **AI instrumental generation** via sherpa-onnx source separation
36
+ - **Wildcard/batch processing** with automatic vocal detection
37
+ - **Transcript save/reuse** for faster reprocessing
38
+ - **Config file** support with sensible defaults
39
+
40
+ ## How It Works
41
+
42
+ 1. Speech recognition produces word-level timestamps (using Groq, Whisper, or Vosk)
43
+ 2. Each word is checked against a built-in profanity list (or your custom list)
44
+ 3. FFmpeg creates a cleaned audio file by either muting, beeping, or replacing profanity sections with instrumental audio
45
+ 4. Optionally, transcripts can be saved and reused to skip transcription on future runs
46
+
47
+ If provided a video file, monkeyplug processes the audio stream and remultiplexes it with the original video stream.
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ pip install monkeyplug-enhanced
53
+ ```
54
+
55
+ Or install from GitHub:
56
+
57
+ ```bash
58
+ pip install 'git+https://github.com/ljbred08/monkeyplug'
59
+ ```
60
+
61
+ ### Prerequisites
62
+
63
+ - **FFmpeg** — install via your OS package manager or from [ffmpeg.org](https://www.ffmpeg.org/download.html)
64
+ - **Python 3.6+**
65
+ - **Groq API key** (for default mode) — see [Groq API Setup](#groq-api-setup)
66
+ - Optional: [Whisper](https://github.com/openai/whisper) or [Vosk](https://github.com/alphacep/vosk-api) for offline recognition
67
+
68
+ ## Groq API Setup
69
+
70
+ The default mode uses Groq's fast Whisper API. Configure your API key using one of these methods (in order of priority):
71
+
72
+ **Command-line parameter:**
73
+ ```bash
74
+ monkeyplug -i input.mp3 -o output.mp3 --groq-api-key gsk_...
75
+ ```
76
+
77
+ **Environment variable:**
78
+ ```bash
79
+ export GROQ_API_KEY=gsk_...
80
+ ```
81
+
82
+ **Config file** (`~/.groq/config.json`):
83
+ ```json
84
+ {"api_key": "gsk_..."}
85
+ ```
86
+
87
+ **Project-local file** (add `.groq_key` to `.gitignore`):
88
+ ```bash
89
+ echo 'gsk_...' > .groq_key
90
+ ```
91
+
92
+ ## Quick Start
93
+
94
+ ```bash
95
+ # Basic usage — mutes profanity using Groq API and built-in word list
96
+ monkeyplug -i song.mp3 -o song_clean.mp3
97
+
98
+ # Verbose output to see what's happening
99
+ monkeyplug -i song.mp3 -o song_clean.mp3 -v
100
+
101
+ # Use local Whisper instead of Groq
102
+ monkeyplug -i song.mp3 -o song_clean.mp3 -m whisper
103
+ ```
104
+
105
+ ## Censorship Modes
106
+
107
+ Three modes are available. Priority order: `--mute` > `--beep` > `--instrumental`.
108
+
109
+ ### Mute
110
+
111
+ Silences profanity sections with short fade transitions.
112
+
113
+ ```bash
114
+ monkeyplug -i song.mp3 -o song_clean.mp3 --mute
115
+ ```
116
+
117
+ ### Beep
118
+
119
+ Replaces profanity with a beep tone.
120
+
121
+ ```bash
122
+ # Basic beep
123
+ monkeyplug -i song.mp3 -o song_clean.mp3 -b
124
+
125
+ # Customize beep frequency and mix
126
+ monkeyplug -i song.mp3 -o song_clean.mp3 -b -z 1000 --beep-mix-normalize
127
+ ```
128
+
129
+ ### Instrumental
130
+
131
+ Replaces profanity sections with instrumental audio for a professional-sounding clean edit. Supports several sub-modes:
132
+
133
+ #### Provide an instrumental file directly
134
+
135
+ ```bash
136
+ monkeyplug -i explicit.mp3 -o clean.mp3 --instrumental instrumental.mp3
137
+ ```
138
+
139
+ #### Auto mode (default)
140
+
141
+ Searches for an instrumental file using fuzzy matching. If not found, falls back to AI generation.
142
+
143
+ ```bash
144
+ # Default behavior — searches for matching instrumental, generates if not found
145
+ monkeyplug -i song.mp3 -o song_clean.mp3 --instrumental auto
146
+
147
+ # This is also the default when no --instrumental flag is given
148
+ monkeyplug -i song.mp3 -o song_clean.mp3
149
+ ```
150
+
151
+ AUTO fuzzy matching searches the same directory for audio files with similar names (30% similarity threshold). Examples:
152
+ - `1-satisfied.mp3` → finds `satisfied-inst.mp3`
153
+ - `MySong_v2.mp3` → finds `MySong_instrumental.mp3`
154
+
155
+ #### Prefix search
156
+
157
+ Searches for instrumental files using a specific prefix/suffix pattern:
158
+
159
+ ```bash
160
+ # Searches for: song_inst.mp3, song-inst.mp3, inst_song.mp3, etc.
161
+ monkeyplug -i song.mp3 -o song_clean.mp3 --instrumental prefix --instrumental-prefix inst
162
+ ```
163
+
164
+ #### AI Generation (force)
165
+
166
+ Uses sherpa-onnx to AI-generate instrumental sections for profanity segments. Skips all instrumental file searching.
167
+
168
+ ```bash
169
+ monkeyplug -i song.mp3 -o song_clean.mp3 --instrumental generate
170
+ ```
171
+
172
+ The AI separation process:
173
+ 1. Extracts profanity segments from the original audio
174
+ 2. Concatenates them with configurable padding (default: 1.0s)
175
+ 3. Separates vocals from instrumental using a Spleeter model
176
+ 4. Splices the AI-generated instrumental back into the original
177
+
178
+ Separation models are cached at `~/.cache/monkeyplug/separation_models/` (downloaded on first use).
179
+
180
+ ## Wildcard / Batch Mode
181
+
182
+ Process multiple files at once using `*` wildcards:
183
+
184
+ ```bash
185
+ # Process all MP3s in current directory
186
+ monkeyplug -i "*.mp3" -o "*_clean.mp3" --instrumental generate
187
+
188
+ # With verbose output
189
+ monkeyplug -i "*.mp3" -o "*_clean.mp3 -v
190
+ ```
191
+
192
+ ### Vocal detection
193
+
194
+ In wildcard mode, monkeyplug automatically detects which files have vocals by transcribing a 10-second sample from the middle of each file. Instrumental files (no speech detected) are skipped.
195
+
196
+ With `--instrumental generate`, vocal detection is **skipped by default** (all files are processed) since you're generating instrumentals anyway. Use `--filter-instrumentals` to re-enable it:
197
+
198
+ ```bash
199
+ # Process all files (default — no vocal detection)
200
+ monkeyplug -i "*.mp3" -o "*_clean.mp3" --instrumental generate
201
+
202
+ # Skip files detected as instrumentals
203
+ monkeyplug -i "*.mp3" -o "*_clean.mp3" --instrumental generate --filter-instrumentals
204
+ ```
205
+
206
+ Files matching the output pattern are automatically skipped (already processed).
207
+
208
+ ## Transcript Workflow
209
+
210
+ Save and reuse transcripts to avoid redundant API calls (up to 22x faster on repeat runs):
211
+
212
+ ```bash
213
+ # Generate and save transcript alongside output
214
+ monkeyplug -i song.mp3 -o song_clean.mp3 --save-transcript
215
+ # Creates: song_clean.mp3 + song_clean_transcript.json
216
+
217
+ # Second run: automatically finds and reuses the transcript
218
+ monkeyplug -i song.mp3 -o song_clean.mp3 --save-transcript
219
+
220
+ # Force new transcription (ignore existing transcript)
221
+ monkeyplug -i song.mp3 -o song_clean.mp3 --save-transcript --force-retranscribe
222
+
223
+ # Manually specify a transcript to load
224
+ monkeyplug -i song.mp3 -o song_clean_strict.mp3 --input-transcript song_clean_transcript.json -w strict_swears.txt
225
+ ```
226
+
227
+ ## Custom Profanity Lists
228
+
229
+ ```bash
230
+ # Use a custom text file (one word per line, or word|replacement)
231
+ monkeyplug -i podcast.mp3 -o podcast_clean.mp3 -w custom_swears.txt
232
+
233
+ # Use a custom JSON file (array of strings)
234
+ monkeyplug -i podcast.mp3 -o podcast_clean.mp3 -w custom_swears.json
235
+
236
+ # Custom words are merged with the built-in profanity list
237
+ ```
238
+
239
+ ## Config File
240
+
241
+ monkeyplug looks for a JSON config file in this order (first found wins):
242
+
243
+ 1. `./.monkeyplug.json` (current directory — project-specific)
244
+ 2. `~/.cache/monkeyplug/config.json` (user-specific)
245
+
246
+ If neither exists, a default config is auto-created at `~/.cache/monkeyplug/config.json`:
247
+
248
+ ```json
249
+ {
250
+ "pad_milliseconds": 10,
251
+ "pad_milliseconds_pre": 10,
252
+ "pad_milliseconds_post": 10,
253
+ "separation_padding": 1.0,
254
+ "beep_hertz": 1000
255
+ }
256
+ ```
257
+
258
+ Config values provide defaults that can be overridden by CLI arguments.
259
+
260
+ Clean all caches (models, config) with:
261
+
262
+ ```bash
263
+ monkeyplug --clean-cache
264
+ ```
265
+
266
+ ## Padding Control
267
+
268
+ Add padding around profanity for smoother transitions:
269
+
270
+ ```bash
271
+ # Equal padding on both sides
272
+ monkeyplug -i song.mp3 -o clean.mp3 --pad-milliseconds 100
273
+
274
+ # Different pre and post padding
275
+ monkeyplug -i song.mp3 -o clean.mp3 --pad-milliseconds-pre 50 --pad-milliseconds-post 100
276
+ ```
277
+
278
+ ## Full Usage Reference
279
+
280
+ ```
281
+ usage: monkeyplug <arguments>
282
+
283
+ Core Options:
284
+ -i, --input <string> Input file, URL, or wildcard pattern
285
+ -o, --output <string> Output file or pattern
286
+ -v [concise|full], --verbose Verbose output
287
+ -m [groq|whisper|vosk], --mode Speech recognition engine (default: groq)
288
+
289
+ Censorship Modes:
290
+ --mute Mute profanity (disables instrumental mode)
291
+ -b, --beep Beep instead of silence
292
+ --instrumental <mode|file> Instrumental mode: auto, generate, prefix, or file path
293
+ --instrumental-prefix <string> Prefix to search for instrumental file (default: AUTO)
294
+ --instrumental-auto-candidates <int> Top candidates for AUTO matching (default: 5)
295
+
296
+ Profanity:
297
+ -w, --swears <file> Custom profanity list (text or JSON)
298
+ --pad-milliseconds <int> Padding around profanity (default: 10)
299
+ --pad-milliseconds-pre <int> Padding before profanity (default: 10)
300
+ --pad-milliseconds-post <int> Padding after profanity (default: 10)
301
+
302
+ Beep Options:
303
+ -z, --beep-hertz <int> Beep frequency in Hz (default: 1000)
304
+ --beep-mix-normalize Normalize audio/beep mix
305
+ --beep-audio-weight <int> Non-beeped audio weight (default: 1)
306
+ --beep-sine-weight <int> Beep weight (default: 1)
307
+ --beep-dropout-transition <int> Dropout transition for beep (default: 0)
308
+
309
+ Transcript:
310
+ --save-transcript Save transcript JSON alongside output
311
+ --input-transcript <file> Load existing transcript JSON
312
+ --output-json <file> Save transcript to specific file
313
+ --force-retranscribe Force new transcription
314
+
315
+ AI Separation:
316
+ --separation-padding <seconds> Context padding for AI generation (default: 1.0)
317
+ --filter-instrumentals Filter out instrumental files in wildcard mode with generate
318
+
319
+ Audio Output:
320
+ -f, --format <string> Output format (default: inferred from extension or "MATCH")
321
+ -c, --channels <int> Output channels (default: 2)
322
+ -s, --sample-rate <int> Output sample rate (default: 48000)
323
+ -r, --bitrate <string> Output bitrate (default: 256K)
324
+ -a, --audio-params <string> FFmpeg audio parameters
325
+ -q, --vorbis-qscale <int> qscale for libvorbis (default: 5)
326
+
327
+ Other:
328
+ --force Process file even if already tagged
329
+ --clean-cache Delete all cached data (models, config) and exit
330
+
331
+ Groq Options:
332
+ --groq-api-key <string> Groq API key
333
+ --groq-model <string> Groq Whisper model (default: whisper-large-v3)
334
+
335
+ Whisper Options:
336
+ --whisper-model-dir <string> Model directory (default: ~/.cache/whisper)
337
+ --whisper-model-name <string> Model name (default: small.en)
338
+ --torch-threads <int> CPU inference threads (default: 0)
339
+
340
+ VOSK Options:
341
+ --vosk-model-dir <string> Model directory (default: ~/.cache/vosk)
342
+ --vosk-read-frames-chunk <int> WAV frame chunk (default: 8000)
343
+ ```
344
+
345
+ ## Docker
346
+
347
+ Docker images are available for running monkeyplug in containers. See [mmguero/monkeyplug](https://github.com/mmguero/monkeyplug) for available images.
348
+
349
+ ## Contributing
350
+
351
+ Pull requests welcome!
352
+
353
+ ## Authors
354
+
355
+ - **Seth Grover** - Initial work - [mmguero](https://github.com/mmguero)
356
+ - **Lincoln Brown** - Enhanced fork (Groq API, AI generation, batch mode) - [ljbred08](https://github.com/ljbred08)
357
+
358
+ ## License
359
+
360
+ BSD 3-Clause License — see the [LICENSE](LICENSE) file for details.