Skip to content

Instantly share code, notes, and snippets.

@evmcheb
Created October 11, 2019 10:22
Show Gist options
  • Save evmcheb/536f6c2cd0a340bd4ff3e99a66b98db9 to your computer and use it in GitHub Desktop.
Save evmcheb/536f6c2cd0a340bd4ff3e99a66b98db9 to your computer and use it in GitHub Desktop.
using scaper to simulate chainsaw noises in a forest
import scaper, os
soundscape_duration = 30.0
outfolder = 'soundscapes/'
foreground = os.path.expanduser("foreground")
background = os.path.expanduser("background")
sc = scaper.Scaper(soundscape_duration, foreground, background)
sc.add_background(label=("const", "rainforest"),
source_file=("choose", []),
source_time=("uniform", 0, 300-soundscape_duration))
for i in range(1000):
audiofile = outfolder+f'/normal_{i}.wav'
jamsfile = outfolder+f'/normal_{i}.jams'
sc.generate(audiofile, jamsfile,
allow_repeated_label=True,
allow_repeated_source=True,
disable_sox_warnings=True,
no_audio=False,
txt_path=None)
sc.add_event(label=("const", "chainsaw"),
source_file=("choose", []),
source_time=("uniform", 10, 30),
event_time=("const", 0),
event_duration=("const", 30),
snr=("uniform", -5, 0),
pitch_shift=("uniform", -15, 15),
time_stretch=None)
for i in range(1000):
audiofile = outfolder+f'/soundscape_{i}.wav'
jamsfile = outfolder+f'/soundscape_{i}.jams'
sc.generate(audiofile, jamsfile,
allow_repeated_label=True,
allow_repeated_source=True,
disable_sox_warnings=True,
no_audio=False,
txt_path=None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment