Skip to content

Commit

Permalink
Minor docstring fixes following #55
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsalamon committed Feb 22, 2020
1 parent dc0d8f9 commit f633b0e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
20 changes: 9 additions & 11 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,14 @@ This is especially useful for generating datasets that can be used to train and
source separation algorithms or models. To enable this, two additional arguments can be
given to ``generate()`` and ``generate_from_jams()``:

isolated_events_path:


isolated_events_path:

* ``save_isolated_events``: whether or not to save the audio corresponding to the
to the isolated foreground events and backgrounds within the synthesized soundscape.
In our example, there are three components - the background and the two foreground events.
* ``isolated_events_path``: the path where the audio corresponding to the isolated
foreground events and backgrounds will be saved. If None (default) and
save_isolated_events = True, the events are saved to <parentdir>/_events/, where
save_isolated_events = True, the events are saved to <parentdir>/<audiofilename>_events/, where
<parentdir> is the parent folder of the soundscape audio file provided in the
audiofile parameter in the example below:

Expand All @@ -350,9 +348,9 @@ The code above will produce the following directory structure:
~/scaper_output/mysoundscape.jams
~/scaper_output/mysoundscape.txt
~/scaper_output/mysoundscape_events/
background0_<label0>.wav
foreground0_<label0>.wav
foreground1_<label1>.wav
background0_<label>.wav
foreground0_<label>.wav
foreground1_<label>.wav
The labels for each isolated event are determined after ``generate`` is called.
If ``isolated_events_path`` were specified, then it would produce:
Expand All @@ -362,10 +360,10 @@ If ``isolated_events_path`` were specified, then it would produce:
~/scaper_output/mysoundscape.wav
~/scaper_output/mysoundscape.jams
~/scaper_output/mysoundscape.txt
~/scaper_output/<isolated_events_path>/
background0_<label0>.wav
foreground0_<label0>.wav
foreground1_<label1>.wav
<isolated_events_path>/
background0_<label>.wav
foreground0_<label>.wav
foreground1_<label>.wav
The audio of the isolated events is guaranteed to sum up to the soundscape audio if and
only if ``reverb`` is ``None``! The audio of the isolated events as well as the audio
Expand Down
2 changes: 1 addition & 1 deletion scaper/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ def match_sample_length(audio_path, duration_in_samples):

audio = np.pad(audio, pad_width, 'constant')

soundfile.write(audio_path, audio, sr)
soundfile.write(audio_path, audio, sr)
59 changes: 32 additions & 27 deletions scaper/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ def generate_from_jams(jams_infile, audio_outfile, fg_path=None, bg_path=None,
a new JAMS files where the source file paths match the new fg_path
and/or bg_path.
save_isolated_events : bool
If True, this will save the isolated event audio in a directory adjacent to the soundscape
If True, this will save the isolated event audio in a directory adjacent to the generated soundscape
mixture, or to the path defined by `isolated_events_path`. The audio of the isolated events sum
up to the mixture if reverb is not applied. Isolated events can be found
(by default) at `<audio_outfile parent folder>/<audio_outfile name>_events`.
Isolated event file names follow the pattern: `[role][count]_[label]`, where count
Isolated event file names follow the pattern: `<role><idx>_<label>`, where idx
is the index of the isolated event in
self.fg_spec or self.bg_spec (this allows events of the same label to be added more than
once to the soundscape without breaking things). Role is "background" or "foreground".
For example: `foreground0_siren.wav` or `background0_park.wav`.
isolated_events_path : str
Like `audio_outfile`, this determines the path of the directory within which
the isolated event audio will be saved.
Path to folder for saving isolated events. If None, defaults to
`<audio_outfile parent folder>/<audio_outfile name>_events`.
Raises
------
Expand Down Expand Up @@ -1641,19 +1641,21 @@ def _generate_audio(self, audio_path, ann, reverb=None,
(default) to prevent the soundscape from going through the reverb
module at all.
save_isolated_events : bool
If True, this will save the isolated event audio in a directory adjacent to the soundscape
mixture, or to the path defined by `isolated_events_path`. The audio of the isolated events sum
up to the mixture if reverb is not applied. Isolated events can be found
(by default) at `<audio_outfile parent folder>/<audio_outfile name>_events`.
Isolated event file names follow the pattern: `[role][count]_[label]`, where count
is the index of the isolated event in
self.fg_spec or self.bg_spec (this allows events of the same label to be added more than
once to the soundscape without breaking things). Role is "background" or "foreground".
For example: `foreground0_siren.wav` or `background0_park.wav`.
If True, this will save the isolated foreground events and
backgrounds in a directory adjacent to the generated soundscape
mixture, or to the path defined by `isolated_events_path`. The
audio of the isolated events sum up to the mixture if reverb is not
applied. Isolated events can be found (by default) at
`<audio_outfile parent folder>/<audio_outfile name>_events`.
Isolated event file names follow the pattern: `<role><idx>_<label>`,
where idx is the index of the isolated event in self.fg_spec or
self.bg_spec (this allows events of the same label to be added more
than once to the soundscape without breaking things). Role is
"background" or "foreground". For example: `foreground0_siren.wav`
or `background0_park.wav`.
isolated_events_path : str
Like `audio_path`, this determines the path of the directory within which
the isolated event audio will be saved. If None, defaults to the parent
folder of audio_path.
Path to folder for saving isolated events. If None, defaults to
`<audio_path parent folder>/<audio_path name>_events`.
disable_sox_warnings : bool
When True (default), warnings from the pysox module are suppressed
unless their level is ``'CRITICAL'``.
Expand Down Expand Up @@ -1904,18 +1906,21 @@ def generate(self, audio_path, jams_path, allow_repeated_label=True,
(default) to prevent the soundscape from going through the reverb
module at all.
save_isolated_events : bool
If True, this will save the isolated event audio in a directory adjacent to the soundscape
mixture, or to the path defined by `isolated_events_path`. The audio of the isolated events sum
up to the mixture if reverb is not applied. Isolated events can be found
(by default) at `<audio_outfile parent folder>/<audio_outfile name>_events`.
Isolated event file names follow the pattern: `[role][count]_[label]`, where count
is the index of the isolated event in
self.fg_spec or self.bg_spec (this allows events of the same label to be added more than
once to the soundscape without breaking things). Role is "background" or "foreground".
For example: `foreground0_siren.wav` or `background0_park.wav`.
If True, this will save the isolated foreground events and
backgrounds in a directory adjacent to the generated soundscape
mixture, or to the path defined by `isolated_events_path`. The
audio of the isolated events sum up to the mixture if reverb is not
applied. Isolated events can be found (by default) at
`<audio_outfile parent folder>/<audio_outfile name>_events`.
Isolated event file names follow the pattern: `<role><idx>_<label>`,
where count is the index of the isolated event in self.fg_spec or
self.bg_spec (this allows events of the same label to be added more
than once to the soundscape without breaking things). Role is
"background" or "foreground". For example: `foreground0_siren.wav`
or `background0_park.wav`.
isolated_events_path : str
Like `audio_outfile`, this determines the path of the directory within which
the isolated event audio will be saved.
Path to folder for saving isolated events. If None, defaults to
`<audio_path parent folder>/<audio_path name>_events`.
disable_sox_warnings : bool
When True (default), warnings from the pysox module are suppressed
unless their level is ``'CRITICAL'``. If you're experiencing issues related
Expand Down

0 comments on commit f633b0e

Please sign in to comment.