Skip to content

Commit 4e4bbc6

Browse files
chore(format): run black on dev (#727)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c06f1d4 commit 4e4bbc6

File tree

1 file changed

+57
-23
lines changed

1 file changed

+57
-23
lines changed

ChatTTS/utils/dl.py

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ def check_model(
4242
os.remove(bakfile)
4343
return True
4444

45-
def check_folder(base_dir: Path, *innder_dirs: str, names: Tuple[str], sha256_map: Dict[str, str], update=False) -> bool:
45+
46+
def check_folder(
47+
base_dir: Path,
48+
*innder_dirs: str,
49+
names: Tuple[str],
50+
sha256_map: Dict[str, str],
51+
update=False,
52+
) -> bool:
4653
key = "sha256_"
4754
current_dir = base_dir
4855
for d in innder_dirs:
@@ -51,41 +58,62 @@ def check_folder(base_dir: Path, *innder_dirs: str, names: Tuple[str], sha256_ma
5158

5259
for model in names:
5360
menv = model.replace(".", "_")
54-
if not check_model(
55-
current_dir, model, sha256_map[f"{key}{menv}"], update
56-
):
61+
if not check_model(current_dir, model, sha256_map[f"{key}{menv}"], update):
5762
return False
5863
return True
5964

65+
6066
def check_all_assets(base_dir: Path, sha256_map: Dict[str, str], update=False) -> bool:
6167
logger.get_logger().info("checking assets...")
6268

63-
if not check_folder(base_dir, "asset", names=(
64-
"Decoder.pt",
65-
"DVAE_full.pt",
66-
"Embed.safetensors",
67-
"Vocos.pt",
68-
), sha256_map=sha256_map, update=update):
69+
if not check_folder(
70+
base_dir,
71+
"asset",
72+
names=(
73+
"Decoder.pt",
74+
"DVAE_full.pt",
75+
"Embed.safetensors",
76+
"Vocos.pt",
77+
),
78+
sha256_map=sha256_map,
79+
update=update,
80+
):
6981
return False
7082

71-
if not check_folder(base_dir, "asset", "gpt", names=(
72-
"config.json",
73-
"model.safetensors",
74-
), sha256_map=sha256_map, update=update):
83+
if not check_folder(
84+
base_dir,
85+
"asset",
86+
"gpt",
87+
names=(
88+
"config.json",
89+
"model.safetensors",
90+
),
91+
sha256_map=sha256_map,
92+
update=update,
93+
):
7594
return False
7695

77-
if not check_folder(base_dir, "asset", "tokenizer", names=(
78-
"special_tokens_map.json",
79-
"tokenizer_config.json",
80-
"tokenizer.json",
81-
), sha256_map=sha256_map, update=update):
96+
if not check_folder(
97+
base_dir,
98+
"asset",
99+
"tokenizer",
100+
names=(
101+
"special_tokens_map.json",
102+
"tokenizer_config.json",
103+
"tokenizer.json",
104+
),
105+
sha256_map=sha256_map,
106+
update=update,
107+
):
82108
return False
83109

84110
logger.get_logger().info("all assets are already latest.")
85111
return True
86112

87113

88-
def download_and_extract_tar_gz(url: str, folder: str, headers: Optional[Dict[str, str]] = None):
114+
def download_and_extract_tar_gz(
115+
url: str, folder: str, headers: Optional[Dict[str, str]] = None
116+
):
89117
import tarfile
90118

91119
logger.get_logger().info(f"downloading {url}")
@@ -99,7 +127,9 @@ def download_and_extract_tar_gz(url: str, folder: str, headers: Optional[Dict[st
99127
logger.get_logger().info(f"extracted into {folder}")
100128

101129

102-
def download_and_extract_zip(url: str, folder: str, headers: Optional[Dict[str, str]] = None):
130+
def download_and_extract_zip(
131+
url: str, folder: str, headers: Optional[Dict[str, str]] = None
132+
):
103133
import zipfile
104134

105135
logger.get_logger().info(f"downloading {url}")
@@ -158,13 +188,17 @@ def download_all_assets(tmpdir: str, version="0.2.8"):
158188
os.chmod(cmdfile, 0o755)
159189
subprocess.run([cmdfile, "-notui", "-w", "0", "assets/chtts"])
160190
except Exception:
161-
BASE_URL = "https://gitea.seku.su/fumiama/RVC-Models-Downloader/releases/download/"
191+
BASE_URL = (
192+
"https://gitea.seku.su/fumiama/RVC-Models-Downloader/releases/download/"
193+
)
162194
suffix = "zip" if is_win else "tar.gz"
163195
RVCMD_URL = BASE_URL + f"v{version}/rvcmd_{system_type}_{architecture}.{suffix}"
164196
download_dns_yaml(
165197
"https://gitea.seku.su/fumiama/RVC-Models-Downloader/raw/branch/main/dns.yaml",
166198
tmpdir,
167-
headers={"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0"},
199+
headers={
200+
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0"
201+
},
168202
)
169203
if is_win:
170204
download_and_extract_zip(RVCMD_URL, tmpdir)

0 commit comments

Comments
 (0)