Skip to content

Commit

Permalink
mute: Update Spleeter to 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDrHax committed Apr 3, 2021
1 parent 7dceda3 commit 535e436
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'mute': [
'numpy<1.19.0,>=1.16.0',
'tensorflow==2.3.0',
'spleeter>=2.0'
'spleeter==2.2.1'
]
}

Expand Down
15 changes: 8 additions & 7 deletions twitch_utils/mute.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Usage: twitch_utils mute [options] <input> <range>... (-o <name>)
"""Usage: twitch_utils mute [options] <input> <range>... -o <output>
This script attempts to separate streamer's voice from background music by
using Spleeter. Only specified time ranges are affected. Output contains the
Expand All @@ -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.',
Expand All @@ -42,13 +42,13 @@ def ptime(t: str) -> float:

def main(argv=None):
args = docopt(__doc__, argv=argv)

fi = Clip(args['<input>'])
fo = args['-o']
ranges = list(tuple(ptime(t) for t in range.split('~'))
for range in args['<range>'])

loader = get_default_audio_adapter()
loader = AudioAdapter.default()
sample_rate = 44100
separator = Separator('spleeter:2stems')

Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -118,5 +118,6 @@ def main(argv=None):
os.unlink(fo)
raise Exception('ffmpeg exited with non-zero code')


if __name__ == '__main__':
main()
main()

0 comments on commit 535e436

Please sign in to comment.