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

Speed sampling in speed augmentation is counterintuitive #207

Closed
mikolajpabiszczak opened this issue Feb 12, 2021 · 0 comments
Closed

Speed sampling in speed augmentation is counterintuitive #207

mikolajpabiszczak opened this issue Feb 12, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@mikolajpabiszczak
Copy link

Currently speed augmentation (nlpaug/augmenter/audio/speed.py) behaves counterintuitively to what user may expect. Namely, the method for get_random_factor as defined there:

    def get_random_factor(self):
        speeds = [round(i, 1) for i in np.arange(self.factor[0], self.factor[1], 0.1)]
        speeds = [s for s in speeds if s != 1.0]
        return speeds[np.random.randint(len(speeds))]

results in very small number of possible speeds used, e.g. for factor=(0.9, 1.1) there will be 3 values of speeds used (0.9, 1.0, 1.1). In particular, even lower amount of audio (than user would expect) will be augmented as there 1:3 probability that we sample the value 1.0!

User expects uniform sampling from the interval given by factor, so the get_random_factor should look like:

    def get_random_factor(self):
        return  (self.factor[1] - self.factor[0]) * np.random.random_sample + self.factor[0]
@makcedward makcedward added the enhancement New feature or request label Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants