Script adjustments and fixes

This commit is contained in:
James Betker 2021-09-12 21:26:45 -06:00
parent 76e2c497f7
commit bc603c3231
3 changed files with 11 additions and 13 deletions

View File

@ -11,12 +11,11 @@ from scripts.audio.preparation.spleeter_dataset import SpleeterDataset
def main():
src_dir = 'F:\\split\\podcast-dump0'
output_dir = 'F:\\tmp\\out'
output_dir_bg = 'F:\\tmp\\bg'
output_dir_reject = 'F:\\tmp\\rejected'
src_dir = 'F:\\split\\joe_rogan'
output_dir = 'F:\\split\\cleaned\\joe_rogan'
output_dir_bg = 'F:\\split\\background-noise\\joe_rogan'
output_sample_rate=22050
batch_size=24
batch_size=16
dl = DataLoader(SpleeterDataset(src_dir, output_sample_rate), batch_size=batch_size, shuffle=False, num_workers=1, pin_memory=True)
separator = Separator('pretrained_models/2stems', input_sr=output_sample_rate)
@ -45,8 +44,7 @@ def main():
out_sound = bg
else:
print(f"Reject {paths[j]}: {ratio}")
od = output_dir_reject
out_sound = wave
continue
# Strip out channels.
if len(out_sound.shape) > 1:

View File

@ -15,11 +15,11 @@ def main():
parser.add_argument('--path')
parser.add_argument('--out')
args = parser.parse_args()
minimum_duration = 5
minimum_duration = 2
maximum_duration = 20
files = find_audio_files(args.path, include_nonwav=True)
for e, wav_file in enumerate(tqdm(files)):
#if e < 4197:
#if e < 1326:
# continue
print(f"Processing {wav_file}..")
outdir = os.path.join(args.out, f'{e}_{os.path.basename(wav_file[:-4])}').replace('.', '').strip()

View File

@ -13,9 +13,9 @@ import numpy as np
# 1. Audio has little to no background noise, saved to "output_dir"
# 2. Audio has a lot of background noise, bg noise split off and saved to "output_dir_bg"
if __name__ == '__main__':
src_dir = 'F:\\split\\books1'
output_dir = 'F:\\split\\cleaned\\books1'
output_dir_bg = 'F:\\split\\background-noise\\books1'
src_dir = 'F:\\split\\joe_rogan'
output_dir = 'F:\\split\\cleaned\\joe_rogan'
output_dir_bg = 'F:\\split\\background-noise\\joe_rogan'
output_sample_rate=22050
os.makedirs(output_dir_bg, exist_ok=True)
@ -63,4 +63,4 @@ if __name__ == '__main__':
if len(os.shape) > 1:
os = os[:, 0] # Just use the first channel.
wavfile.write(osp.join(od, f'{e}_{file_basis}.wav'), output_sample_rate, os)
wavfile.write(osp.join(od, file_basis, f'{e}.wav'), output_sample_rate, os)