torchaudio.kaldi_io¶
To use this module, the dependency kaldi_io needs to be installed.
This is a light wrapper around kaldi_io
that returns torch.Tensor
.
Vectors¶
read_vec_int_ark¶
-
torchaudio.kaldi_io.
read_vec_int_ark
(file_or_fd)[source]¶ Create generator of (key,vector<int>) tuples, which reads from the ark file/stream.
Parameters: file_or_fd (str/FileDescriptor) – ark, gzipped ark, pipe or opened file descriptor Returns: The string is the key and the tensor is the vector read from file Return type: Generator[str, torch.Tensor] - Example
>>> # read ark to a 'dictionary' >>> d = { u:d for u,d in torchaudio.kaldi_io.read_vec_int_ark(file) }
read_vec_flt_scp¶
-
torchaudio.kaldi_io.
read_vec_flt_scp
(file_or_fd)[source]¶ Create generator of (key,vector<float32/float64>) tuples, read according to Kaldi scp.
Parameters: file_or_fd (str/FileDescriptor) – scp, gzipped scp, pipe or opened file descriptor Returns: The string is the key and the tensor is the vector read from file Return type: Generator[str, torch.Tensor] - Example
>>> # read scp to a 'dictionary' >>> # d = { u:d for u,d in torchaudio.kaldi_io.read_vec_flt_scp(file) }
read_vec_flt_ark¶
-
torchaudio.kaldi_io.
read_vec_flt_ark
(file_or_fd)[source]¶ Create generator of (key,vector<float32/float64>) tuples, which reads from the ark file/stream.
Parameters: file_or_fd (str/FileDescriptor) – ark, gzipped ark, pipe or opened file descriptor Returns: The string is the key and the tensor is the vector read from file Return type: Generator[str, torch.Tensor] - Example
>>> # read ark to a 'dictionary' >>> d = { u:d for u,d in torchaudio.kaldi_io.read_vec_flt_ark(file) }
Matrices¶
read_mat_scp¶
-
torchaudio.kaldi_io.
read_mat_scp
(file_or_fd)[source]¶ Create generator of (key,matrix<float32/float64>) tuples, read according to Kaldi scp.
Parameters: file_or_fd (str/FileDescriptor) – scp, gzipped scp, pipe or opened file descriptor Returns: The string is the key and the tensor is the matrix read from file Return type: Generator[str, torch.Tensor] - Example
>>> # read scp to a 'dictionary' >>> d = { u:d for u,d in torchaudio.kaldi_io.read_mat_scp(file) }
read_mat_ark¶
-
torchaudio.kaldi_io.
read_mat_ark
(file_or_fd)[source]¶ Create generator of (key,matrix<float32/float64>) tuples, which reads from the ark file/stream.
Parameters: file_or_fd (str/FileDescriptor) – ark, gzipped ark, pipe or opened file descriptor Returns: The string is the key and the tensor is the matrix read from file Return type: Generator[str, torch.Tensor] - Example
>>> # read ark to a 'dictionary' >>> d = { u:d for u,d in torchaudio.kaldi_io.read_mat_ark(file) }