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

add 3 augmentor class and relate unittest #108

Merged
merged 13 commits into from
Jun 27, 2017
Merged

Conversation

chrisxu2016
Copy link
Contributor

@chrisxu2016 chrisxu2016 commented Jun 20, 2017

fix #107

add VolumePerturbAugmentor, SpeedPerturbAugmentor, ResampleAugmentor, online_bayesian_normalization class for audio augmentation

change the module of resample , original module:scikits.samplerate , new module: resampy

@chrisxu2016 chrisxu2016 changed the title add augmentor class add 3 augmentor class and relate unittest Jun 20, 2017
Copy link
Contributor

@xinghai-sun xinghai-sun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost LGTM.

@@ -321,21 +321,19 @@ def normalize_online_bayesian(self,
gain_db = target_db - rms_estimate_db
self.apply_gain(gain_db)

def resample(self, target_sample_rate, quality='sinc_medium'):
def resample(self, target_sample_rate, filter='kaiser_best'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between sinc_median and kaiser_best? Please make sure that they have equivalent effects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有差别,因为这两种resample使用的拟合函数不一样,但是实际效果差不多

"""

def __init__(self, rng, min_speed_rate, max_speed_rate):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove L24

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


def __init__(self, rng, min_speed_rate, max_speed_rate):

if (min_speed_rate < 0.5):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "(" and ")". The same in L28.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


def __init__(self, rng, min_speed_rate, max_speed_rate):

if (min_speed_rate < 0.5):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 0.5 or 0.9? It is inconsistent with the error message.
  2. Please also add this explanation in function doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

:param audio: Audio segment to add effects to.
:type audio: AudioSegment|SpeechSegment
"""
audio_segment.resample(self._new_sample_rate)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"No newline at the end of file" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -7,6 +7,9 @@
import random
from data_utils.augmentor.volume_perturb import VolumePerturbAugmentor
from data_utils.augmentor.shift_perturb import ShiftPerturbAugmentor
from data_utils.augmentor.speed_perturb import SpeedPerturbAugmentor
from data_utils.augmentor.resample import ResampleAugmentor
from data_utils.augmentor.online_bayesian_normalization import OnlineBayesianNormalizationAugmentor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this longer than 80 columns?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -14,20 +14,21 @@ class SpeedPerturbAugmentor(AugmentorBase):

:param rng: Random generator object.
:type rng: random.Random
:param min_speed_rate: Lower bound of new speed rate to sample.
:param min_speed_rate: Lower bound of new speed rate to sample and should
not below 0.9.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--> should not be below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

:param rng: Random generator object.
:type rng: random.Random
:param min_speed_rate: Lower bound of new speed rate to sample and should
not below 0.9.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--> should not be smaller than

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

not below 0.9.
:type min_speed_rate: float
:param max_speed_rate: Upper bound of new speed rate to sample and should
not above 1.1.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--> should not be larger than

audio_seg = audio.AudioSegment(audio_data, samplerate)
aug_pipeline.transform_audio(audio_seg)
orig_audio = audio.AudioSegment(audio_data, samplerate)
self.assertFalse(np.any(audio_seg.samples == orig_audio.samples))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's meaningless to do such a "non-equal" test. Just please remove this Augmentor unitest.

@chrisxu2016 chrisxu2016 merged commit 08ab956 into develop Jun 27, 2017
@chrisxu2016 chrisxu2016 deleted the new_augmentation branch June 27, 2017 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add data augmentor class
2 participants