espnet2.fileio.vad_scp.VADScpWriter
espnet2.fileio.vad_scp.VADScpWriter
class espnet2.fileio.vad_scp.VADScpWriter(scpfile: Path | str, dtype=None)
Bases: object
Writer class for ‘vad.scp’.
This class provides functionality to write Voice Activity Detection (VAD) data to a ‘vad.scp’ file. The VAD data is represented as utterance-level segments, which can be used to guide silence trimming for tasks like Unsupervised Automatic Speech Recognition (UASR).
scpfile
The path to the ‘vad.scp’ file.
- Type: Path
dtype
Data type for the VAD values (optional).
data
A dictionary to store VAD entries.
Type: dict
Parameters:
- scpfile (Union *[*Path , str ]) – Path to the output ‘vad.scp’ file.
- dtype – Data type for the VAD values (default is None).
Examples
key1 0:1.2000 key2 3.0000:4.5000 7.0000:9.0000 …
>>> writer = VADScpWriter('./data/vad.scp')
>>> writer['aa'] = [(0.0, 1.2), (2.0, 3.0)]
>>> writer['bb'] = [(3.0, 4.5)]
- Raises:AssertionError – If a duplicate key is found or if the provided value is not a list of tuples with exactly two elements each.
NOTE
Ensure that the keys used are unique within the VAD entries to avoid overwriting data.
close()
Writer class for ‘vad.scp’.
This class is responsible for writing voice activity detection (VAD) data to a file in the ‘vad.scp’ format. The format consists of keys associated with time intervals, indicating when speech is detected. This is useful for applications such as automatic speech recognition (ASR) to manage silence trimming.
The output format is as follows: : key1 0:1.2000 key2 3.0000:4.5000 7.0000:9.0000 …
Examples: : ```python
writer = VADScpWriter('./data/vad.scp') writer['aa'] = [(0.0, 1.2), (2.0, 3.5)] writer['bb'] = [(1.0, 2.0)]
Attributes: : scpfile (Path): The path to the output ‘vad.scp’ file. dtype (optional): Data type for the VAD intervals. data (dict): A dictionary to store the VAD data associated with keys.
Args: : scpfile (Union[Path, str]): The path to the ‘vad.scp’ file to be created. dtype (optional): Data type for the VAD intervals. Defaults to None.
Raises: : AssertionError: If a duplicate key is found or if the value is not a list : of tuples.
Note: : This class should be used in a context manager to ensure that the file is properly closed after writing.
Todo: : - Implement additional validation for the input VAD tuples.