espnet.utils.cli_readers.file_reader_helper
Less than 1 minute
espnet.utils.cli_readers.file_reader_helper
espnet.utils.cli_readers.file_reader_helper(rspecifier: str, filetype: str = 'mat', return_shape: bool = False, segments: str | None = None)
Read uttid and array in kaldi style
This function might be a bit confusing as “ark” is used for HDF5 to imitate “kaldi-rspecifier”.
- Parameters:
- rspecifier – Give as “ark:feats.ark” or “scp:feats.scp”
- filetype – “mat” is kaldi-martix, “hdf5”: HDF5
- return_shape – Return the shape of the matrix, instead of the matrix. This can reduce IO cost for HDF5.
- Return type:Generator[Tuple[str, np.ndarray], None, None]
Examples
Read from kaldi-matrix ark file:
>>> for u, array in file_reader_helper('ark:feats.ark', 'mat'):
... array
Read from HDF5 file:
>>> for u, array in file_reader_helper('ark:feats.h5', 'hdf5'):
... array