Script adjustments and fixes
This commit is contained in:
parent
76e2c497f7
commit
bc603c3231
|
@ -11,12 +11,11 @@ from scripts.audio.preparation.spleeter_dataset import SpleeterDataset
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
src_dir = 'F:\\split\\podcast-dump0'
|
src_dir = 'F:\\split\\joe_rogan'
|
||||||
output_dir = 'F:\\tmp\\out'
|
output_dir = 'F:\\split\\cleaned\\joe_rogan'
|
||||||
output_dir_bg = 'F:\\tmp\\bg'
|
output_dir_bg = 'F:\\split\\background-noise\\joe_rogan'
|
||||||
output_dir_reject = 'F:\\tmp\\rejected'
|
|
||||||
output_sample_rate=22050
|
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)
|
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)
|
separator = Separator('pretrained_models/2stems', input_sr=output_sample_rate)
|
||||||
|
@ -45,8 +44,7 @@ def main():
|
||||||
out_sound = bg
|
out_sound = bg
|
||||||
else:
|
else:
|
||||||
print(f"Reject {paths[j]}: {ratio}")
|
print(f"Reject {paths[j]}: {ratio}")
|
||||||
od = output_dir_reject
|
continue
|
||||||
out_sound = wave
|
|
||||||
|
|
||||||
# Strip out channels.
|
# Strip out channels.
|
||||||
if len(out_sound.shape) > 1:
|
if len(out_sound.shape) > 1:
|
||||||
|
|
|
@ -15,11 +15,11 @@ def main():
|
||||||
parser.add_argument('--path')
|
parser.add_argument('--path')
|
||||||
parser.add_argument('--out')
|
parser.add_argument('--out')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
minimum_duration = 5
|
minimum_duration = 2
|
||||||
maximum_duration = 20
|
maximum_duration = 20
|
||||||
files = find_audio_files(args.path, include_nonwav=True)
|
files = find_audio_files(args.path, include_nonwav=True)
|
||||||
for e, wav_file in enumerate(tqdm(files)):
|
for e, wav_file in enumerate(tqdm(files)):
|
||||||
#if e < 4197:
|
#if e < 1326:
|
||||||
# continue
|
# continue
|
||||||
print(f"Processing {wav_file}..")
|
print(f"Processing {wav_file}..")
|
||||||
outdir = os.path.join(args.out, f'{e}_{os.path.basename(wav_file[:-4])}').replace('.', '').strip()
|
outdir = os.path.join(args.out, f'{e}_{os.path.basename(wav_file[:-4])}').replace('.', '').strip()
|
|
@ -13,9 +13,9 @@ import numpy as np
|
||||||
# 1. Audio has little to no background noise, saved to "output_dir"
|
# 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"
|
# 2. Audio has a lot of background noise, bg noise split off and saved to "output_dir_bg"
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
src_dir = 'F:\\split\\books1'
|
src_dir = 'F:\\split\\joe_rogan'
|
||||||
output_dir = 'F:\\split\\cleaned\\books1'
|
output_dir = 'F:\\split\\cleaned\\joe_rogan'
|
||||||
output_dir_bg = 'F:\\split\\background-noise\\books1'
|
output_dir_bg = 'F:\\split\\background-noise\\joe_rogan'
|
||||||
output_sample_rate=22050
|
output_sample_rate=22050
|
||||||
|
|
||||||
os.makedirs(output_dir_bg, exist_ok=True)
|
os.makedirs(output_dir_bg, exist_ok=True)
|
||||||
|
@ -63,4 +63,4 @@ if __name__ == '__main__':
|
||||||
if len(os.shape) > 1:
|
if len(os.shape) > 1:
|
||||||
os = os[:, 0] # Just use the first channel.
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user