espnet2.fileio.sound_scp.SoundScpReader
espnet2.fileio.sound_scp.SoundScpReader
class espnet2.fileio.sound_scp.SoundScpReader(fname, dtype=None, always_2d: bool = False, multi_columns: bool = False, concat_axis=1)
Bases: Mapping
Reader class for ‘wav.scp’.
Examples
wav.scp is a text file that looks like the following:
key1 /some/path/a.wav key2 /some/path/b.wav key3 /some/path/c.wav key4 /some/path/d.wav …
>>> reader = SoundScpReader('wav.scp')
>>> rate, array = reader['key1']
If multi_columns=True is given and multiple files are given in one line with space delimiter, and the output array are concatenated along channel direction
key1 /some/path/a.wav /some/path/a2.wav key2 /some/path/b.wav /some/path/b2.wav …
>>> reader = SoundScpReader('wav.scp', multi_columns=True)
>>> rate, array = reader['key1']
In the above case, a.wav and a2.wav are concatenated.
Note that even if multi_columns=True is given, SoundScpReader still supports a normal wav.scp, i.e., a wav file is given per line, but this option is disable by default because dict[str, list[str]] object is needed to be kept, but it increases the required amount of memory.
get_path(key)
keys() → a set-like object providing a view on D's keys