espnet2.fileio.sound_scp.SoundScpWriter
Less than 1 minute
espnet2.fileio.sound_scp.SoundScpWriter
class espnet2.fileio.sound_scp.SoundScpWriter(outdir: Path | str, scpfile: Path | str, format='wav', multi_columns: bool = False, output_name_format: str = '{key}.{audio_format}', output_name_format_multi_columns: str = '{key}-CH{channel}.{audio_format}', subtype: str | None = None)
Bases: object
Writer class for ‘wav.scp’
- Parameters:
- outdir
- scpfile
- format – The output audio format
- multi_columns – Save multi channel data as multiple monaural audio files
- output_name_format – The naming formam of generated audio files
- output_name_format_multi_columns – The naming formam of generated audio files when multi_columns is given
- dtype
- subtype
Examples
>>> writer = SoundScpWriter('./data/', './data/wav.scp')
>>> writer['aa'] = 16000, numpy_array
>>> writer['bb'] = 16000, numpy_array
aa ./data/aa.wav bb ./data/bb.wav
>>> writer = SoundScpWriter(
'./data/', './data/feat.scp', multi_columns=True,
)
>>> numpy_array.shape
(100, 2)
>>> writer['aa'] = 16000, numpy_array
aa ./data/aa-CH0.wav ./data/aa-CH1.wav
close()
get_path(key)