espnet2.fileio.read_text.read_label
espnet2.fileio.read_text.read_label
espnet2.fileio.read_text.read_label(path: Path | str) → Dict[str, List[List[str | float | int]]]
Read a text file indicating sequences of numbers or labels.
This function reads a text file where each line consists of a key followed by a sequence of associated values. The values are expected to be in the format of start time, end time, and label for each segment. The output is a dictionary where each key maps to a list of lists containing the parsed information.
espnet2.fileio.read_text.path
The file path of the text file to be read.
Type: Union[Path, str]
Parameters:path – A string or Path object representing the path to the text file.
Returns: A dictionary where each key corresponds to a sequence of labels and associated timing information, with the values being lists of lists that contain the start time, end time, and label.
Return type: Dict[str, List[List[Union[str, float, int]]]]
Examples
Given a file ‘label.txt’ with the following content: : key1 0.1 0.2 “啊” 0.3 0.4 “喔” key2 0.5 0.6 “哦”
The function can be used as follows: : ```python
d = read_label('label.txt') print(d) {'key1': [['0.1', '0.2', '啊'], ['0.3', '0.4', '喔']], 'key2': [['0.5', '0.6', '哦']]}
##### NOTE
The input file must be formatted correctly, with each line
starting with a unique key followed by the respective data.
* **Raises:**
* **FileNotFoundError** – If the specified file does not exist.
* **IndexError** – If a line in the file does not contain enough values
to be parsed correctly.