• Docs >
  • torchaudio.kaldi_io >
  • Current (stable)
Shortcuts

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: Any) Iterable[Tuple[str, Tensor]][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:

Iterable[Tuple[str, 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: Any) Iterable[Tuple[str, Tensor]][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:

Iterable[Tuple[str, 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: Any) Iterable[Tuple[str, Tensor]][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:

Iterable[Tuple[str, 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: Any) Iterable[Tuple[str, Tensor]][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:

Iterable[Tuple[str, 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: Any) Iterable[Tuple[str, Tensor]][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:

Iterable[Tuple[str, Tensor]]

Example
>>> # read ark to a 'dictionary'
>>> d = { u:d for u,d in torchaudio.kaldi_io.read_mat_ark(file) }

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources