diff --git a/README.md b/README.md index 9e20db6..7bba588 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,12 @@ options: Beep instead of silence -h , --beep-hertz Beep frequency hertz (default: 1000) + --beep-audio-weight + Mix weight for non-beeped audio (default: 4) + --beep-sine-weight + Mix weight for beep (default: 1) + --beep-dropout-transition + Dropout transition for beep (default: 0) --force [true|false] Process file despite existence of embedded tag VOSK Options: diff --git a/setup.cfg b/setup.cfg index 88c8627..e1b5c3a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = monkeyplug -version = 2.1.0 +version = 2.1.1 author = Seth Grover author_email = mero.mero.guero@gmail.com description = monkeyplug is a little script to censor profanity in audio files. diff --git a/src/monkeyplug/__init__.py b/src/monkeyplug/__init__.py index 469e8e0..ebf5c95 100644 --- a/src/monkeyplug/__init__.py +++ b/src/monkeyplug/__init__.py @@ -1,6 +1,6 @@ """monkeyplug is a little script to censor profanity in audio files.""" -__version__ = "2.1.0" +__version__ = "2.1.1" __author__ = "Seth Grover " __all__ = [] diff --git a/src/monkeyplug/monkeyplug.py b/src/monkeyplug/monkeyplug.py index dc7ceac..907c6dd 100755 --- a/src/monkeyplug/monkeyplug.py +++ b/src/monkeyplug/monkeyplug.py @@ -44,6 +44,9 @@ AUDIO_INTERMEDIATE_PARAMS = ["-c:a", "pcm_s16le", "-ac", "1", "-ar", "16000"] AUDIO_DEFAULT_WAV_FRAMES_CHUNK = 8000 BEEP_HERTZ_DEFAULT = 1000 +BEEP_AUDIO_WEIGHT_DEFAULT = 4 +BEEP_SINE_WEIGHT_DEFAULT = 1 +BEEP_DROPOUT_TRANSITION_DEFAULT = 0 SWEARS_FILENAME_DEFAULT = 'swears.txt' MUTAGEN_METADATA_TAGS = ['encodedby', 'comment'] MUTAGEN_METADATA_TAG_VALUE = u'monkeyplug' @@ -211,6 +214,9 @@ class Plugger(object): padSecPost = 0.0 beep = False beepHertz = BEEP_HERTZ_DEFAULT + beepAudioWeight = BEEP_AUDIO_WEIGHT_DEFAULT + beepSineWeight = BEEP_SINE_WEIGHT_DEFAULT + beepDropTransition = BEEP_DROPOUT_TRANSITION_DEFAULT forceDespiteTag = False aParams = None tags = None @@ -229,6 +235,9 @@ def __init__( padMsecPost=0, beep=False, beepHertz=BEEP_HERTZ_DEFAULT, + beepAudioWeight=BEEP_AUDIO_WEIGHT_DEFAULT, + beepSineWeight=BEEP_SINE_WEIGHT_DEFAULT, + beepDropTransition=BEEP_DROPOUT_TRANSITION_DEFAULT, force=False, dbug=False, ): @@ -236,6 +245,9 @@ def __init__( self.padSecPost = padMsecPost / 1000.0 self.beep = beep self.beepHertz = beepHertz + self.beepAudioWeight = beepAudioWeight + self.beepSineWeight = beepSineWeight + self.beepDropTransition = beepDropTransition self.forceDespiteTag = force self.debug = dbug self.outputJson = outputJson @@ -347,7 +359,11 @@ def __init__( mmguero.eprint(f'Profanity file: {self.swearsFileSpec}') mmguero.eprint(f'Intermediate downloaded file: {self.tmpDownloadedFileSpec}') mmguero.eprint(f'Beep instead of mute: {self.beep}') - mmguero.eprint(f'Beep hertz: {self.beepHertz}') + if self.beep: + mmguero.eprint(f'Beep hertz: {self.beepHertz}') + mmguero.eprint(f'Beep audio weight: {self.beepAudioWeight}') + mmguero.eprint(f'Beep sine weight: {self.beepSineWeight}') + mmguero.eprint(f'Beep dropout transition: {self.beepDropTransition}') mmguero.eprint(f'Force despite tags: {self.forceDespiteTag}') ######## del ################################################################## @@ -420,7 +436,7 @@ def EncodeCleanAudio(self): [f'[beep{i+1}]{val}[beep{i+1}_delayed]' for i, val in enumerate(self.beepDelayList)] ) beepMixList = ''.join([f'[beep{i+1}_delayed]' for i in range(len(self.beepDelayList))]) - filterStr = f"[0:a]{muteTimeListStr}[mute];{sineTimeListStr};{beepDelayList};[mute]{beepMixList}amix=inputs={len(self.beepDelayList)+1}" + filterStr = f"[0:a]{muteTimeListStr}[mute];{sineTimeListStr};{beepDelayList};[mute]{beepMixList}amix=inputs={len(self.beepDelayList)+1}:dropout_transition={self.beepDropTransition}:weights={self.beepAudioWeight} {' '.join([str(self.beepSineWeight)] * len(self.beepDelayList))}" audioArgs = ['-filter_complex', filterStr] else: audioArgs = ['-af', ",".join(self.muteTimeList)] @@ -506,6 +522,9 @@ def __init__( padMsecPost=0, beep=False, beepHertz=BEEP_HERTZ_DEFAULT, + beepAudioWeight=BEEP_AUDIO_WEIGHT_DEFAULT, + beepSineWeight=BEEP_SINE_WEIGHT_DEFAULT, + beepDropTransition=BEEP_DROPOUT_TRANSITION_DEFAULT, force=False, dbug=False, ): @@ -539,6 +558,9 @@ def __init__( padMsecPost=padMsecPost, beep=beep, beepHertz=beepHertz, + beepAudioWeight=beepAudioWeight, + beepSineWeight=beepSineWeight, + beepDropTransition=beepDropTransition, force=force, dbug=dbug, ) @@ -655,6 +677,9 @@ def __init__( padMsecPost=0, beep=False, beepHertz=BEEP_HERTZ_DEFAULT, + beepAudioWeight=BEEP_AUDIO_WEIGHT_DEFAULT, + beepSineWeight=BEEP_SINE_WEIGHT_DEFAULT, + beepDropTransition=BEEP_DROPOUT_TRANSITION_DEFAULT, force=False, dbug=False, ): @@ -678,6 +703,9 @@ def __init__( padMsecPost=padMsecPost, beep=beep, beepHertz=beepHertz, + beepAudioWeight=beepAudioWeight, + beepSineWeight=beepSineWeight, + beepDropTransition=beepDropTransition, force=force, dbug=dbug, ) @@ -848,6 +876,31 @@ def RunMonkeyPlug(): default=BEEP_HERTZ_DEFAULT, help=f"Beep frequency hertz (default: {BEEP_HERTZ_DEFAULT})", ) + parser.add_argument( + "--beep-audio-weight", + dest="beepAudioWeight", + metavar="", + type=int, + default=BEEP_AUDIO_WEIGHT_DEFAULT, + help=f"Mix weight for non-beeped audio (default: {BEEP_AUDIO_WEIGHT_DEFAULT})", + ) + parser.add_argument( + "--beep-sine-weight", + dest="beepSineWeight", + metavar="", + type=int, + default=BEEP_SINE_WEIGHT_DEFAULT, + help=f"Mix weight for beep (default: {BEEP_SINE_WEIGHT_DEFAULT})", + ) + parser.add_argument( + "--beep-dropout-transition", + dest="beepDropTransition", + metavar="", + type=int, + default=BEEP_DROPOUT_TRANSITION_DEFAULT, + help=f"Dropout transition for beep (default: {BEEP_DROPOUT_TRANSITION_DEFAULT})", + ) + parser.add_argument( "--force", dest="forceDespiteTag", @@ -926,6 +979,9 @@ def RunMonkeyPlug(): padMsecPost=args.padMsecPost if args.padMsecPost > 0 else args.padMsec, beep=args.beep, beepHertz=args.beepHertz, + beepAudioWeight=args.beepAudioWeight, + beepSineWeight=args.beepSineWeight, + beepDropTransition=args.beepDropTransition, force=args.forceDespiteTag, dbug=args.debug, ) @@ -946,6 +1002,9 @@ def RunMonkeyPlug(): padMsecPost=args.padMsecPost if args.padMsecPost > 0 else args.padMsec, beep=args.beep, beepHertz=args.beepHertz, + beepAudioWeight=args.beepAudioWeight, + beepSineWeight=args.beepSineWeight, + beepDropTransition=args.beepDropTransition, force=args.forceDespiteTag, dbug=args.debug, )