File size: 1,554 Bytes
24303c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import shutil
from tqdm import tqdm
def main():
    old_prefix = '/home/rcell/genshin_data/'
    new_prefix = '/home/rcell/data/magvits_data/'
    file_list_path = '/home/rcell/data/magvits_reborn/dump/val_files_gs.list'
    extensions = ['.latent.pt', '.lab', '.spk.npy', '.ssl.pt']

    # 读取文件列表
    with open(file_list_path, 'r') as f:
        wav_files = [line.strip() for line in f if line.strip()]

    for src_wav in tqdm(wav_files):
        if not src_wav.startswith(old_prefix):
            print(f"Warning: Path {src_wav} doesn't start with {old_prefix}")
            continue

        # 生成目标路径
        dest_wav = src_wav.replace(old_prefix, new_prefix, 1)
        dest_dir = os.path.dirname(dest_wav)
        
        # 创建目标目录
        os.makedirs(dest_dir, exist_ok=True)
        
        # 复制原始wav文件
        try:
            shutil.copy2(src_wav, dest_wav)
        except FileNotFoundError:
            print(f"源文件不存在: {src_wav}")
            continue

        # 处理扩展文件
        assert src_wav.endswith('.wav'), "源文件必须以.wav结尾"
        base_name = src_wav[:-4]  # 去掉.wav后缀
        for ext in extensions:
            src_file = f"{base_name}{ext}"
            dest_file = os.path.join(dest_dir, os.path.basename(src_file))
            
            try:
                shutil.copy2(src_file, dest_file)
            except FileNotFoundError:
                print(f"扩展文件不存在: {src_file}")

if __name__ == "__main__":
    main()