From 061bd2cbab947be94ab472440c7eefbaeb2cfb5f Mon Sep 17 00:00:00 2001 From: pseeth Date: Wed, 3 Apr 2019 13:09:51 -0500 Subject: [PATCH] adding save_sources to generate_from_jams --- scaper/core.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scaper/core.py b/scaper/core.py index 46fd38a..3b9522b 100644 --- a/scaper/core.py +++ b/scaper/core.py @@ -47,7 +47,7 @@ def generate_from_jams(jams_infile, audio_outfile, fg_path=None, bg_path=None, - jams_outfile=None): + jams_outfile=None, save_sources=False): ''' Generate a soundscape based on an existing scaper JAMS file and save to disk. @@ -75,6 +75,13 @@ def generate_from_jams(jams_infile, audio_outfile, fg_path=None, bg_path=None, saved. Useful when either fg_path or bg_path is not None, as it saves a new JAMS files where the source file paths match the new fg_path and/or bg_path. + save_sources : bool + If True, this will save the sources in a directory adjacent to the generated + mixture. The sources sum up to the mixture. Sources can be found at + `[audio_path]_sources/foreground` and `[audio_path]_sources/background'. + Source audio names follow the pattern: `[role]_[label][count]`, where count + is the index of the source in self.fg_spec (this allows sources of the same + label to be added more than once to the soudscape without breaking things). Raises ------ @@ -144,10 +151,11 @@ def generate_from_jams(jams_infile, audio_outfile, fg_path=None, bg_path=None, # Generate audio and save to disk reverb = ann.sandbox.scaper['reverb'] - sc._generate_audio(audio_outfile, ann, reverb=reverb, + sc._generate_audio(audio_outfile, ann, reverb=reverb, save_sources=save_sources, disable_sox_warnings=True) # If there are slice (trim) operations, need to perform them! + # Need to add this logic for the sources too? if 'slice' in ann.sandbox.keys(): for sliceop in ann.sandbox['slice']: # must use temp file in order to save to same file