def split_and_save(input_file, current_split, args):
    (wav, sr) = torchaudio.load(input_file)
    chunk_size = (args.split_size * sr)
    (quotient, remainder) = divmod(wav.size(1), chunk_size)
    sections = [chunk_size for _ in range(quotient)]
    sections.append(remainder)
    splitted_wav = torch.split(wav, split_size_or_sections=sections, dim=1)
    check_sum = 0
    for (i, w) in enumerate(splitted_wav):
        check_sum += w.size(1)
        file_name = os.path.basename(input_file).split('.')[0]
        new_file_name = file_name.replace(file_name, ((file_name + '-') + str(i)))
        new_file_path = input_file.replace(current_split, (current_split + args.name))
        new_file_path = new_file_path.replace(file_name, new_file_name)
        if (args.input_path != args.output_path):
            new_file_path = new_file_path.replace(args.input_path, args.output_path)
        os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
        torchaudio.save(new_file_path, w, sr)
    assert (check_sum == wav.size(1))
def split_and_save(input_file, current_split, args):
    (wav, sr) = torchaudio.load(input_file)
    chunk_size = (args.split_size * sr)
    (quotient, remainder) = divmod(wav.size(1), chunk_size)
    sections = [chunk_size for _ in range(quotient)]
    sections.append(remainder)
    splitted_wav = torch.split(wav, split_size_or_sections=sections, dim=1)
    check_sum = 0
    for (i, w) in enumerate(splitted_wav):
        check_sum += w.size(1)
        file_name = os.path.basename(input_file).split('.')[0]
        new_file_name = file_name.replace(file_name, ((file_name + '-') + str(i)))
        new_file_path = input_file.replace(current_split, (current_split + args.name))
        new_file_path = new_file_path.replace(file_name, new_file_name)
        if (args.input_path != args.output_path):
            new_file_path = new_file_path.replace(args.input_path, args.output_path)
        os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
        torchaudio.save(new_file_path, w, sr)
    assert (check_sum == wav.size(1))