-
Notifications
You must be signed in to change notification settings - Fork 742
Add Torchscript sox effects #760
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
Conversation
96cbfb4 to
a53314e
Compare
Codecov Report
@@ Coverage Diff @@
## master #760 +/- ##
==========================================
+ Coverage 89.53% 89.66% +0.13%
==========================================
Files 32 34 +2
Lines 2617 2652 +35
==========================================
+ Hits 2343 2378 +35
Misses 274 274
Continue to review full report at Codecov.
|
90098e6 to
75c8b51
Compare
|
Is it possible to split this up a bit more into smaller PRs or would that result in unreasonable amount of work? |
6ad1e13 to
78858a4
Compare
ea0b9e0 to
b2ba4dc
Compare
@cpuhrsch I spliced the PR into logical commits. I can still make them separate PRs if necessary, but this way, we do not need to worry about merge conflict between them. Let me know if you feel separate PRs is better. The commits are basically about
|
b2ba4dc to
4ef41ad
Compare
|
btw, could you add a example code snippet to the description to showcase how to use the new interface? with old-new syntax comparison? |
@vincentqb Updated the docstring and added examples I will add migration message in the next PR in which deprecation messages are added to the existing |
e5c716d to
2d41e38
Compare
Cool!
That's even better. I initially meant to simply add instructions in the description of this PR as a first step. |
f55a67b to
a17fffb
Compare
|
cc @eugene-kharitonov for interest in applying sox effects to tensors directly without using files :) |
Is there value in having an overloaded function that switched between the two depending on input? |
|
|
||
|
|
||
| @_mod_utils.requires_module('torchaudio._torchaudio') | ||
| def set_buffer_size(buffer_size: int): |
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.
When I see functions like these, I understand that there are global parameters behind the scene to manage the sox_effects_chain. Is that the case? Is there a way here to have many chains with different such settings?
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.
When I see functions like these, I understand that there are global parameters behind the scene to manage the
sox_effects_chain. Is that the case?
Yes
Is there a way here to have many chains with different such settings?
Nope
|
|
||
| enum SoxEffectsResourceState { NotInitialized, Initialized, ShutDown }; | ||
| SoxEffectsResourceState SOX_RESOURCE_STATE = NotInitialized; | ||
| std::mutex SOX_RESOUCE_STATE_MUTEX; |
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.
So the code is thread safe through this global lock, right?
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.
So the code is thread safe through this global lock, right?
Yes.
| const c10::intrusive_ptr<TensorSignal>& signal, | ||
| const double compression) { | ||
| const auto tensor = signal->getTensor(); | ||
| const auto sample_rate = signal->getSampleRate(); |
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.
nit: what do people do to get sample rate then?
vincentqb
left a comment
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.
LGTM with a few clarifying questions. Thanks for grouping the changes into logical commits. Separate PR would have made it easier to associate descriptions with each changes though, at least for the reader :)
No. |
|
Thanks! |
Update Dynamic Quant BERT Tutorial 4
This PR add new sox effects functions
torchaudio.sox_effects.apply_effects_tensorandtorchaudio.sox_effects.apply_effects_file, which applies sox effects to Tensor object and file object respectively.This new functions are written from scratch to take advantage of Torchscript, and tested on various effects by comparing against the results from
soxcommand. The existingtorchaudio.sox_effects.SoxEffectsChaindoes not have this and it does not work correctly on certain format (see #771 )Also this PR adds
torchaudio.utils.sox_utilsmodule, which allows users to set verbosity, multi-threading option, buffer size and get the list of supported effects/formats.Off topic: @cpuhrsch I was adding some tests on data loader with
num_workers > 1. This test example applies speed perturbation, which alters the length of input Tensor. It would be interesting if we can combinenestedtensorthere.https://github.com/mthrok/audio/blob/sox-effects-chain/test/sox_effect/test_dataset.py#L17-L63