espnet2.train.dataset.H5FileWrapper
Less than 1 minute
espnet2.train.dataset.H5FileWrapper
class espnet2.train.dataset.H5FileWrapper(path: str)
Bases: object
A wrapper class for handling HDF5 files.
This class provides a convenient interface for reading data from an HDF5 file using the h5py library. It allows users to access datasets stored in the file in a straightforward manner.
path
The file path to the HDF5 file.
- Type: str
h5_file
The opened HDF5 file.
Type: h5py.File
Parameters:path (str) – The path to the HDF5 file to be opened.
Examples
>>> wrapper = H5FileWrapper('data.h5')
>>> print(len(wrapper)) # Output the number of datasets in the file
>>> data = wrapper['dataset_name'] # Access a specific dataset
>>> print(data) # Print the data from the dataset
- Returns: This class does not return any value upon initialization.
- Return type: None
- Raises:
- KeyError – If the requested dataset key does not exist in the file.
- OSError – If the file cannot be opened or read.
NOTE
This class only supports read operations. If you need to write to an HDF5 file, consider using h5py directly.