meta_generator
Author: Heli Qi Affiliation: NAIST Date: 2022.11
SpeechTextMetaGenerator
Bases: ABC
The base class for all metadata generators of datasets. To contribute a new dataset dumping pipeline,
inherit this class in your meta_generator.py and implement the generate_meta_dict abstract method.
Source code in speechain/datasets/meta_generator.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
add_parse(parser)
staticmethod
Interface for users to add custom arguments. This method can be overridden, but it's not mandatory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parser
|
ArgumentParser
|
The argparse parser to which you want to add your arguments. |
required |
Returns:
| Type | Description |
|---|---|
ArgumentParser
|
argparse.ArgumentParser: The parser containing the custom arguments. |
Source code in speechain/datasets/meta_generator.py
generate_meta_dict(src_path, txt_format, **kwargs)
abstractmethod
Generate a metadata dictionary for the specified dataset. Must be overridden in subclasses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_path
|
str
|
Path to the original dataset. |
required |
txt_format
|
str
|
Text processing format. |
required |
**kwargs
|
Custom arguments for the dataset implementation. |
{}
|
Dict[str, Dict[str, Dict[str, str] or List[str]]]
| Type | Description |
|---|---|
Dict[str, Dict[str, Dict[str, str] or List[str]]]
|
The metadata dictionary you want to save on the disk. |
Dict[str, Dict[str, Dict[str, str] or List[str]]]
|
The first-level keys indicate the names of subsets in the dataset. The second-level keys indicate the names of metadata files you want to save. The third-level elements can be either Dict or List. Dict represents those 'idx2XXX' files where each line contains a file index and corresponding metadata value. List represents those 'XXX' files where each line only contains metadata value without any file indices. |
Source code in speechain/datasets/meta_generator.py
main()
Main entry point for SpeechTextMetaGenerator.
Steps:
1. Obtain metadata dictionary via self.generate_meta_dict.
2. Save the metadata in the given source path, creating a specific folder for each subset.
Source code in speechain/datasets/meta_generator.py
parse()
Parse and declare common arguments shared by all dataset implementations. Current common arguments include: 'src_path', 'tgt_path', and 'txt_format'.
Returns:
| Type | Description |
|---|---|
|
argparse.Namespace: The namespace containing both the general and user-defined arguments. |