File size: 1,146 Bytes
d8c063b
98a8b62
 
d8c063b
98a8b62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d8c063b
ac3ee76
98a8b62
d8c063b
98a8b62
 
 
 
ac3ee76
98a8b62
 
 
 
 
 
 
 
 
d8c063b
98a8b62
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
import os
import csv
import json

ref_path = os.getenv("REF_PATH")
assert ref_path is not None
with open(ref_path, 'r') as f:
    data = json.load(f)
ref = {}
c = 1
for item in data:
    k = item['ref_wav_path']
    ref[k] = {
        'speaker_name': item['up_name'],
        'input_text': item['prompt_text'],
        'tag': item['category'],
        'id': f'{c:03d}'
    }
    c += 1

folders = ['human', 't-large', 'p-preview', 'xunfei', 'doubao', 'openai']
csv_file = 'metadata.csv'

with open(csv_file, mode='w', newline='') as file:
    writer = csv.writer(file)
    writer.writerow(['file_name', 'id', 'speaker_name', 'TTS_method', 'input_text', 'tag'])
    
    for item in os.listdir('human'):
        v = ref[item]
        for folder in folders:
            file_id = item.split('.')[0]
            if folder in ['xunfei', 'doubao']:
                file_name = os.path.join(folder, file_id + '.mp3')
            else:
                file_name = os.path.join(folder, item)
            writer.writerow([file_name, v['id'], v['speaker_name'], folder, v['input_text'], v['tag']])
        writer.writerow([])

print(f"CSV OK: {csv_file}")