Change to use os.path.join

This commit is contained in:
litagin
2023-07-18 19:52:29 +09:00
parent bdaeb7afca
commit 59b32c33d1
2 changed files with 10 additions and 6 deletions

View File

@@ -48,6 +48,8 @@ weights
Each model directory should contain exactly one `.pth` file and at most one `.index` file. Directory names are used as model names.
It seems that non-ASCII characters in path names gave faiss errors (like `weights/モデル1/index.index`), so please avoid them.
## Launch
```bash

14
app.py
View File

@@ -36,10 +36,12 @@ tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voice
tts_voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
model_root = "weights"
models = [d for d in os.listdir(model_root) if os.path.isdir(f"{model_root}/{d}")]
models.sort()
models = [
d for d in os.listdir(model_root) if os.path.isdir(os.path.join(model_root, d))
]
if len(models) == 0:
raise ValueError("No model found in `weights` folder")
models.sort()
hubert_model = None
print("Loading rmvpe model...")
@@ -50,8 +52,8 @@ print("rmvpe model loaded.")
def model_data(model_name):
# global n_spk, tgt_sr, net_g, vc, cpt, version, index_file
pth_files = [
f"{model_root}/{model_name}/{f}"
for f in os.listdir(f"{model_root}/{model_name}")
os.path.join(model_root, model_name, f)
for f in os.listdir(os.path.join(model_root, model_name))
if f.endswith(".pth")
]
if len(pth_files) == 0:
@@ -87,8 +89,8 @@ def model_data(model_name):
# n_spk = cpt["config"][-3]
index_files = [
f"{model_root}/{model_name}/{f}"
for f in os.listdir(f"{model_root}/{model_name}")
os.path.join(model_root, model_name, f)
for f in os.listdir(os.path.join(model_root, model_name))
if f.endswith(".index")
]
if len(index_files) == 0: