-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM.
deep_speech_2/data_utils/audio.py
Outdated
@@ -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'): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove L24
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 0.5 or 0.9? It is inconsistent with the error message.
- Please also add this explanation in function doc.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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" ?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--> should not be below
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
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