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

"Failed to read vector from stream. : Expected token FV, got W" #47

Open
matthewkperez opened this issue Jun 10, 2020 · 0 comments
Open

Comments

@matthewkperez
Copy link

Hello,
I'm getting an error when attempting to use copy-vector on the output of 'kaldi_io.write_vec_int'.

Error is: "Failed to read vector from stream. : Expected token FV, got W"

Goal: I have a large text file of kaldi features. The file is in .ark format however the contents are in human-readable form which I converted using 'copy-feats ark:- ark,t:-'. I want to create multiple small files where each file contains a key and mat pair. To do this I am reading in the ark file using kaldi_io and attempting to write a new file using kaldi_io within the kaldi_io.read_vec_int_ark loop. I am able to successfully read key and mat from the file, but an error occurs when attempting to write.

Code:
`for key, mat in kaldi_io.read_vec_int_ark(sfile):
print("{} {}".format(key,mat.shape))

        ## create new file to write to
        new_file_path_txt = os.path.join(sdir, "{}.{}".format(key, file_tail))
        new_file_path = os.path.join(sdir, "{}.ark".format(key))
        # new_file_path_txt = os.path.join(sdir, "{}.txt".format(key))

        # Write new file
        print("type: {}".format(type(mat)))
        print("dtype: {}".format(mat.dtype))
        mat = mat.astype('int32') # need to cast for writing purposes
        print("dtype2: {}".format(mat.dtype))

        ark_txt_output = 'ark:| copy-vector ark:- ark,t:{}'.format(new_file_path_txt)
        with kaldi_io.open_or_fd(ark_txt_output, 'wb') as w:
            kaldi_io.write_vec_int(w, mat, key=key)`
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

No branches or pull requests

1 participant