espnet2.fileio.rand_gen_dataset.FloatRandomGenerateDataset
Less than 1 minute
espnet2.fileio.rand_gen_dataset.FloatRandomGenerateDataset
class espnet2.fileio.rand_gen_dataset.FloatRandomGenerateDataset(shape_file: Path | str, dtype: str | dtype = 'float32', loader_type: str = 'csv_int')
Bases: Mapping
Generate float arrays from a shape specification file.
This class reads a file containing the shapes of the arrays to be generated. The file should be formatted as follows:
shape.txt uttA 123,83 uttB 34,83
Each line corresponds to a unique identifier and the dimensions of the float array that will be generated.
Examples
>>> dataset = FloatRandomGenerateDataset("shape.txt")
>>> array = dataset["uttA"]
>>> assert array.shape == (123, 83)
>>> array = dataset["uttB"]
>>> assert array.shape == (34, 83)
utt2shape
A mapping from utterance identifiers to their shapes.
- Type: dict
dtype
The data type of the generated arrays.
Type: np.dtype
Parameters:
- shape_file (Union *[*Path , str ]) – The path to the shape specification file.
- dtype (Union *[*str , np.dtype ] , optional) – The data type of the generated arrays. Defaults to “float32”.
- loader_type (str , optional) – The type of loader to use for reading the shape file. Defaults to “csv_int”.
Raises:
- FileNotFoundError – If the specified shape file does not exist.
- ValueError – If the shape file is improperly formatted.