espnet2.fileio.omniio_audio.OmniIOSegmentsReader
Less than 1 minute
espnet2.fileio.omniio_audio.OmniIOSegmentsReader
class espnet2.fileio.omniio_audio.OmniIOSegmentsReader(fname: Path | str, wav_scp: Path | str | None = None, always_2d: bool = False, max_cache_fd: int = 32)
Bases: Mapping
Reader of a Kaldi segments file over a wav.scp of Omni-IO entries.
Examples
segments (wav.scp is read from the same directory): : win1 rec1 0.0 10.0 win2 rec1 10.0 20.0
>>> reader = OmniIOSegmentsReader('dump/raw/train_win/segments')
>>> rate, array = reader['win2']Each segment is cut as SegmentsExtractor cuts it when dumping, but at load time and reading only the segment’s part of the archive entry.
- Parameters:
- fname – The segments file.
- wav_scp – The recordings’ scp; default:
wav.scpnext to fname. - always_2d – Keep the channel axis even for single-channel audio.
- max_cache_fd – Bin files kept open; 0 opens and closes per read.
Read the segments and the recordings’ scp.
close()
Close the bin files this process opened.
keys()
The segment ids.
