read_audio fixes and docs cleanup#1592
Merged
Adel-Moumen merged 5 commits intospeechbrain:developfrom Nov 21, 2022
Merged
Conversation
Collaborator
|
@Adel-Moumen, could you please review it when you have time? |
Collaborator
Yes, sure. 🙂 |
Adel-Moumen
requested changes
Nov 21, 2022
Collaborator
Adel-Moumen
left a comment
There was a problem hiding this comment.
Hello,
Thanks for the PR. Everything looks nice. I tried your PR and everything works as expected.
Could you please add your name at the top of the file?
Thanks again!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using the
dictvariant ofread_audio, omitting the"stop"key would fail due to a breaking change in torchaudio0.8.0(SB currently requires any version newer than0.9.0).While this was undocumented, the code seemed to intend it as possible.
This PR does several things:
The function was cleaned up, with the call to
torchaudio.loadfixed, keeping backwards-compatibility.Added sanity checks, which raise an exception when the start-stop range seems incorrect. Let me know if these are overkill.
It attempts to improve the documentation for
read_audiosignificantly, documenting edge cases and previously undocumented behavior, namelyFollowing this PR, all of these now work:
Tests were added accordingly.
Root cause
Previously, the
num_framesparameter defaulted to0, which meant "load fromframe_offsetthrough the end of file".This is not the case anymore:
num_framesnow defaults to-1, with the same meaning. However, passing0now fails.Implementation details
In order to best match the past intended behavior, if
start == stop, this PR leaves thenum_framesparameter unspecified, which I feel is more intuitive than the previous code here.