From 535e4364f5a9799e9e1b1423d071b074c86bb4b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9A=D0=B0?= =?UTF-8?q?=D1=80=D0=B8=D1=85?= Date: Sun, 4 Apr 2021 01:19:40 +0300 Subject: [PATCH] mute: Update Spleeter to 2.2.1 --- requirements.txt | 2 +- setup.py | 2 +- twitch_utils/mute.py | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index a5b291a9..6ca6002d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,5 @@ docopt==0.6.2 praat-parselmouth==0.3.3 numpy<1.19.0,>=1.16.0 tensorflow==2.3.0 -spleeter==2.0 +spleeter==2.2.1 parse==1.19.0 \ No newline at end of file diff --git a/setup.py b/setup.py index d5c6da4b..35a11870 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ 'mute': [ 'numpy<1.19.0,>=1.16.0', 'tensorflow==2.3.0', - 'spleeter>=2.0' + 'spleeter==2.2.1' ] } diff --git a/twitch_utils/mute.py b/twitch_utils/mute.py index 9af09bb7..062e7c1d 100644 --- a/twitch_utils/mute.py +++ b/twitch_utils/mute.py @@ -1,4 +1,4 @@ -"""Usage: twitch_utils mute [options] ... (-o ) +"""Usage: twitch_utils mute [options] ... -o This script attempts to separate streamer's voice from background music by using Spleeter. Only specified time ranges are affected. Output contains the @@ -24,7 +24,7 @@ try: from spleeter.separator import Separator - from spleeter.audio.adapter import get_default_audio_adapter + from spleeter.audio.adapter import AudioAdapter except ImportError: print('Error: You need to install tdh-twitch-utils[mute] or ' 'tdh-twitch-utils[all] to use this feature.', @@ -42,13 +42,13 @@ def ptime(t: str) -> float: def main(argv=None): args = docopt(__doc__, argv=argv) - + fi = Clip(args['']) fo = args['-o'] ranges = list(tuple(ptime(t) for t in range.split('~')) for range in args['']) - loader = get_default_audio_adapter() + loader = AudioAdapter.default() sample_rate = 44100 separator = Separator('spleeter:2stems') @@ -59,7 +59,7 @@ def main(argv=None): options = ['-vn', '-r', str(sample_rate), '-f', 'wav'] clip = fi.slice(start, end - start, output_options=options)[0] - + for i in range(int(args['--pass'])): waveform, _ = loader.load(clip.path, sample_rate=sample_rate) prediction = separator.separate(waveform) @@ -86,7 +86,7 @@ def main(argv=None): for i, (start, end) in enumerate(ranges): delay = int(start * 1000) filters += f';[{i+1}]' - filters += f'asetnsamples=8192' + filters += 'asetnsamples=8192' filters += f',adelay={delay}|{delay},apad[delay{i+1}]' # Mix muted original track and all processed segments @@ -118,5 +118,6 @@ def main(argv=None): os.unlink(fo) raise Exception('ffmpeg exited with non-zero code') + if __name__ == '__main__': - main() \ No newline at end of file + main()