-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Process .opus files with torchaudio #3667
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.
Sounds good to me :) thanks !
@@ -91,10 +91,11 @@ def decode_example(self, value: dict) -> dict: | |||
raise RuntimeError("Decoding is disabled for this feature. Please use Audio(decode=True) instead.") | |||
|
|||
path, file = (value["path"], BytesIO(value["bytes"])) if value["bytes"] is not None else (value["path"], None) | |||
extension = path.split(".")[-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.
The path can be None here:
extension = path.split(".")[-1] | |
extension = path.split(".")[-1] if path is not None else None |
Note that torchaudio is maybe less practical to use for TF or JAX users. |
@lhoestq so maybe don't do this PR? :) if it doesn't work anyway with an opened file, only with path |
Yes as discussed offline there seems to be issues with torchaudio on opened files. Feel free to close this PR if it's better to stick with soundfile because of that |
We should be able to remove torchaudio, which has torch as a hard dependency, soon and use only soundfile for decoding: bastibe/python-soundfile#252 (comment) (opus + mp3 support is on the way). |
@anton-l suggested to proccess .opus files with
torchaudio
instead ofsoundfile
as it's faster:(moreover, I didn't manage to load .opus files with
soundfile
/librosa
locally on any my machine anyway for some reason, even withffmpeg
installed).For now my current changes work with locally stored file:
But it doesn't work when loading inside s dataset from bytes (I checked on MultilingualSpokenWords, the PR is a draft now, maybe the bug is somewhere there )