-
Notifications
You must be signed in to change notification settings - Fork 739
Add pathlib.Path support to sox_io backend #907
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
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.
Thanks for following-up on comment :)
torchscript tests are failing, and indicate that the union type is not supported by torchscript, see also here. For soundfile, even though functions convert to string and make the code compatible with path, only the string type is in the signature, here. I would be ok having a similar unofficial support for pathlib as is done in soundfile here.
mthrok
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.
Hi @timlod
Thanks for the PR. The signature part is a tricky one, which had slipped from my mind when I was replying in #902.
The "sox_io" backend is designed to be compatible with TorchScript compiler (so that the function works in C++ application too), so types that are specific to Python (in this case, they are Union, Path) cannot be added. Also, because of the way the loading function (in C++) is bound to Python code, we cannot pass file-like object, even though that's common practice in Python.
I checked the intermediate representation that TorchScript compiler generates and filepath = str(filepath) has no effect in TorchScript so this change is good. So just keeping the signature as is should do.
mthrok
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.
Hi @timlod
Thanks for updating the PR. Changes related to the other backends can be omitted from this PR.
mthrok
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.
Looks good, thanks!
Allows for passing of
pathlib.Pathfilepathto sox_io functions.See #902.
For type union docstrings I used (str/pathlib.Path), as I found this pattern was used in the
kaldi_iomethods (for str/FileDescriptor).There may be a better pattern though?