Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pitch augment #27

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions audio_synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def __init__(
self._apply_event_gains = db_config._apply_class_gains
self._db_name = params['db_name']
self._fs = params['fs']
self._pitch_shift = params['random_pitch_shift']
if self._pitch_shift:
self._bins_per_octave = params['bins_per_octave']
self._n_bins_up_down = params['n_bins_up_down']
if self._apply_event_gains:
self._class_gains = db_config._class_gains

Expand Down Expand Up @@ -97,8 +101,9 @@ def synthesize_mixtures(self):
eventsig, fs_db = librosa.load(filename, sr=self._fs) # here we need librosa since we are loading .mp3
else:
raise Exception(f"Unknown event database: {self._db_name}")


if self._pitch_shift:
n_steps = np.random.choice(range(-self._n_bins_up_down,self._n_bins_up_down+1))
eventsig = librosa.effects.pitch_shift(eventsig, sr=fs_db, n_steps=n_steps, bins_per_octave=self._bins_per_octave)


if len(np.shape(eventsig)) > 1:
Expand Down
5 changes: 4 additions & 1 deletion generation_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def get_params(argv='1'):
mixture_duration = 60., #in seconds
event_time_per_layer = 40., #in seconds (should be less than mixture_duration)
audio_format = 'both', # 'foa' (First Order Ambisonics) or 'mic' (four microphones) or 'both'
random_pitch_shift = True,
bins_per_octave = 12,
n_bins_up_down = 6,
)


Expand All @@ -47,7 +50,7 @@ def get_params(argv='1'):
elif argv == '2': ###### FSD50k DATA
params['db_name'] = 'fsd50k'
params['db_path']= '/home/iran/datasets/FSD50K'
params['mixturepath'] = '/datasets/SELD-dataset-sofa'
params['mixturepath'] = '/datasets/SELD-dataset-pitch'
params['active_classes'] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
params['max_polyphony'] = 2

Expand Down