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

Error reading from absolute Windows path #52

Closed
horsti371 opened this issue Dec 9, 2020 · 2 comments · Fixed by #53
Closed

Error reading from absolute Windows path #52

horsti371 opened this issue Dec 9, 2020 · 2 comments · Fixed by #53

Comments

@horsti371
Copy link

Hi,
thank you for your great tool! Unfortunately I have issues reading kaldi matrices / archives from absolute windows pathes, e.g.

my_mat = kaldiio.load_mat(r"C:\temp\my.mat")

The following error occurs:

  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\kaldiio\matio.py", line 232, in load_mat
    ark, offset, slices = _parse_arkpath(ark_name)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\kaldiio\matio.py", line 275, in _parse_arkpath
    offset = int(offset)
ValueError: invalid literal for int() with base 10: '\\temp\\my.mat'

That happens because the absolute path is splitted at ":", to separate the path and offset in kaldi archives. Of course, in this example, "\temp\my_mat" is no valid integer offset.
Changing path using os.chdir and using the filename works, but of course this is a bad solution.
Is there any workaround for this (or maybe I use it wrong)?

@kamo-naoyuki
Copy link
Contributor

i see, thanks, I didn't care about windows, but it's better to support for usability. I'll think how to do.

for workaround,

from kaldiio.matio import read_kaldi
with open(r"C:\temp\my.mat") as f:
    read_kaldi(f)

@horsti371
Copy link
Author

Thanks, that works, opening binary archives in binary read mode.

kamo-naoyuki added a commit to kamo-naoyuki/kaldiio that referenced this issue Dec 10, 2020
@kamo-naoyuki kamo-naoyuki linked a pull request Dec 10, 2020 that will close this issue
kamo-naoyuki added a commit to kamo-naoyuki/kaldiio that referenced this issue Dec 10, 2020
kamo-naoyuki added a commit that referenced this issue Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants