espnet2.fileio.omniio_audio.OmniIOAudioWriter
espnet2.fileio.omniio_audio.OmniIOAudioWriter
class espnet2.fileio.omniio_audio.OmniIOAudioWriter(outdir: Path | str, scpfile: Path | str, format: str = 'flac', bit_depth: int = 16, max_bin_size: int = 335544320)
Bases: object
Write audio into one Omni-IO archive and an scp pointing into it.
The archive is outdir/blob_<i>.bin + outdir/metadata.parquet with the columns that omniio.blob.blob.Blob writes (id, start_byte, end_byte, bin_index, path and the audio metadata of omniio.audio.write.audio_write), so other Omni-IO tools can read it. A new bin file is started once max_bin_size bytes would be exceeded. The writer owns outdir: archive files left there by an earlier run (blob_*.bin, metadata.parquet) are removed when it starts, so a rerun never leaves stale entries behind.
Examples
>>> with OmniIOAudioWriter('dump/format.1/wav', 'dump/format.1/wav.scp') as w:
... w['utt1'] = 16000, numpy_array- Parameters:
- outdir – Archive directory.
- scpfile – The scp file to write.
- format – Audio codec inside the archive (“flac”, “wav” or “webm”).
- bit_depth – PCM bit depth (ignored for “webm”).
- max_bin_size – Maximum size of one bin file in bytes.
Start a new archive in outdir, removing one left by an earlier run.
close()
Finish the archive: write metadata.parquet and close the files.
An archive with no entry leaves no bin and no metadata file. Calling close() again does nothing.
