-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_voicepack.py
More file actions
23 lines (23 loc) · 821 Bytes
/
Copy pathget_voicepack.py
File metadata and controls
23 lines (23 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Распаковывает скачанный voice-pack.zip в ./voices (запускается с cwd = app).
import os, zipfile, shutil
cwd = os.getcwd()
zp = os.path.join(cwd, "voice-pack.zip")
voices = os.path.join(cwd, "voices")
tmp = os.path.join(cwd, "_vp")
os.makedirs(voices, exist_ok=True)
try:
with zipfile.ZipFile(zp) as z:
z.extractall(tmp)
n = 0
for root, _, files in os.walk(tmp):
for f in files:
if f.lower().endswith((".mp3", ".wav", ".flac", ".txt", ".lab")):
shutil.copy(os.path.join(root, f), os.path.join(voices, f)); n += 1
shutil.rmtree(tmp, ignore_errors=True)
try:
os.remove(zp)
except Exception:
pass
print("voice-pack: %d files installed" % n)
except Exception as e:
print("voice-pack skipped:", e)