Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -122,35 +122,71 @@ import shutil
|
|
| 122 |
import datetime
|
| 123 |
|
| 124 |
def save_model(worked_dir,dest_dir):
|
| 125 |
-
worked_dir = "/home/
|
| 126 |
-
dest_dir = "/home/
|
| 127 |
-
|
| 128 |
-
# dest_dir: 目标存储目录
|
| 129 |
if os.listdir(worked_dir):
|
| 130 |
|
| 131 |
now = datetime.datetime.now()
|
| 132 |
-
|
| 133 |
date_str = now.strftime("%Y%m%d%H%M%S")
|
| 134 |
-
|
| 135 |
dest_folder = os.path.join(dest_dir, date_str)
|
| 136 |
-
|
| 137 |
shutil.copytree(worked_dir, dest_folder)
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
return f"模型已成功保存为 {date_str}"
|
| 148 |
else:
|
| 149 |
return "保存失败,模型已保存或已被清除"
|
| 150 |
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
| 154 |
import random
|
| 155 |
|
| 156 |
def infer(text):
|
|
|
|
| 122 |
import datetime
|
| 123 |
|
| 124 |
def save_model(worked_dir,dest_dir):
|
| 125 |
+
worked_dir = "/home/yiho/Personal-TTS-v3/pretrain_work_dir"
|
| 126 |
+
dest_dir = "/home/yiho/Personal-TTS-v3/trained_model"
|
| 127 |
+
|
|
|
|
| 128 |
if os.listdir(worked_dir):
|
| 129 |
|
| 130 |
now = datetime.datetime.now()
|
| 131 |
+
|
| 132 |
date_str = now.strftime("%Y%m%d%H%M%S")
|
| 133 |
+
|
| 134 |
dest_folder = os.path.join(dest_dir, date_str)
|
| 135 |
+
|
| 136 |
shutil.copytree(worked_dir, dest_folder)
|
| 137 |
|
| 138 |
+
# List of files and directories to delete
|
| 139 |
+
files_to_delete = [
|
| 140 |
+
"tmp_voc",
|
| 141 |
+
"tmp_am/ckpt/checkpoint_2400000.pth",
|
| 142 |
+
"orig_model/description",
|
| 143 |
+
"orig_model/.mdl",
|
| 144 |
+
"orig_model/.msc",
|
| 145 |
+
"orig_model/README.md",
|
| 146 |
+
"orig_model/resource",
|
| 147 |
+
"orig_model/description",
|
| 148 |
+
"orig_model/basemodel_16k/sambert",
|
| 149 |
+
"orig_model/basemodel_16k/speaker_embedding",
|
| 150 |
+
"data/duration",
|
| 151 |
+
"data/energy",
|
| 152 |
+
"data/f0",
|
| 153 |
+
"data/frame_energy",
|
| 154 |
+
"data/frame_f0",
|
| 155 |
+
"data/frame_uv",
|
| 156 |
+
"data/mel",
|
| 157 |
+
"data/raw_duration",
|
| 158 |
+
"data/wav",
|
| 159 |
+
"data/am_train.lst",
|
| 160 |
+
"data/am_valid.lst",
|
| 161 |
+
"data/badlist.txt",
|
| 162 |
+
"data/raw_metafile.txt",
|
| 163 |
+
"data/Script.xml",
|
| 164 |
+
"data/train.lst",
|
| 165 |
+
"data/valid.lst",
|
| 166 |
+
"data/se/0_*"
|
| 167 |
+
]
|
| 168 |
+
|
| 169 |
+
for item in files_to_delete:
|
| 170 |
+
item_path = os.path.join(dest_folder, item)
|
| 171 |
+
if os.path.exists(item_path):
|
| 172 |
+
if os.path.isdir(item_path):
|
| 173 |
+
shutil.rmtree(item_path)
|
| 174 |
+
else:
|
| 175 |
+
os.remove(item_path)
|
| 176 |
+
|
| 177 |
+
shutil.rmtree("/home/yiho/Personal-TTS-v3/output_training_data")
|
| 178 |
+
shutil.rmtree("/home/yiho/Personal-TTS-v3/pretrain_work_dir")
|
| 179 |
+
shutil.rmtree("/home/yiho/Personal-TTS-v3/test_wavs")
|
| 180 |
+
|
| 181 |
+
os.mkdir("/home/yiho/Personal-TTS-v3/output_training_data")
|
| 182 |
+
os.mkdir("/home/yiho/Personal-TTS-v3/pretrain_work_dir")
|
| 183 |
+
os.mkdir("/home/yiho/Personal-TTS-v3/test_wavs")
|
| 184 |
+
|
| 185 |
return f"模型已成功保存为 {date_str}"
|
| 186 |
else:
|
| 187 |
return "保存失败,模型已保存或已被清除"
|
| 188 |
|
| 189 |
|
|
|
|
|
|
|
| 190 |
import random
|
| 191 |
|
| 192 |
def infer(text):
|