You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
708 B
Python

from glob import glob
import soundfile
from inference import slicer
import os
from tqdm.auto import tqdm
files = glob("dataset_prepare/arona_channel/**/vocals.wav", recursive=True)
target_prefix = ("dataset_prepare/arona_channel_slice/")
if not os.path.exists(target_prefix):
os.mkdir(target_prefix)
for idx, f in enumerate(tqdm(files)):
tqdm.write(f)
chunks = slicer.cut(f, db_thresh=-50)
audio_data, audio_sr = slicer.chunks2audio(f, chunks)
for idx2, (slice_tag, data) in enumerate(tqdm(audio_data, leave=False)):
if not slice_tag:
res_path = target_prefix + f'aronach_{idx:02d}_{idx2:03d}.wav'
soundfile.write(res_path, data, audio_sr, format="wav")