File size: 1,916 Bytes
f643c3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import os, torch, sys
from subprocess import Popen

now_dir = os.getcwd()
sys.path.append(now_dir)
from config import (
    text_path,
    wav_dir,
    n_card,
    exp_name,
    n_parts,
    exp_dir,
)

os.makedirs("%s/logs_s1" % exp_dir, exist_ok=True)
os.makedirs("%s/logs_s2" % exp_dir, exist_ok=True)
##############step1
ps = []
for i_part in range(n_parts):
    cmd = "python prepare/1-get-text.py %s %s %s %s %s %s" % (
        text_path,
        wav_dir,
        exp_name,
        i_part,
        n_parts,
        i_part % n_card,
    )
    print(cmd)
    p = Popen(cmd, shell=True)
    ps.append(p)
for p in ps:
    p.wait()

opt = []
for i_part in range(n_parts):
    txt_path = "%s/2-name2text-%s.txt" % (exp_dir, i_part)
    with open(txt_path, "r") as f:
        opt += f.read().strip("\n").split("\n")
    os.remove(txt_path)
with open("%s/2-name2text.txt" % exp_dir, "w") as f:
    f.write("\n".join(opt) + "\n")

############step2
ps = []
for i_part in range(n_parts):
    cmd = "python prepare/2-get-hubert-wav32k.py %s %s %s %s %s %s" % (
        text_path,
        wav_dir,
        exp_name,
        i_part,
        n_parts,
        i_part % n_card,
    )
    print(cmd)
    p = Popen(cmd, shell=True)
    ps.append(p)
for p in ps:
    p.wait()
#############step3
ps = []
for i_part in range(n_parts):
    cmd = "python prepare/3-get-semantic.py %s %s %s %s %s" % (
        text_path,
        exp_name,
        i_part,
        n_parts,
        i_part % n_card,
    )
    print(cmd)
    p = Popen(cmd, shell=True)
    ps.append(p)
for p in ps:
    p.wait()
opt = ["item_name	semantic_audio"]
for i_part in range(n_parts):
    semantic_path = "%s/6-name2semantic-%s.tsv" % (exp_dir, i_part)
    with open(semantic_path, "r") as f:
        opt += f.read().strip("\n").split("\n")
    os.remove(semantic_path)
with open("%s/6-name2semantic.tsv" % exp_dir, "w") as f:
    f.write("\n".join(opt) + "\n")