forked from voice-cloning-app/Voice-Cloning-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
52 lines (43 loc) · 1.61 KB
/
main.py
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
import os
import sys
import shutil
import webbrowser
from engineio.async_drivers import threading # noqa
from flask_socketio import SocketIO
from flask import Flask
from application.check_ffmpeg import check_ffmpeg
def load_paths():
paths = {
"datasets": os.path.join("data", "datasets"),
"models": os.path.join("data", "models"),
"pretrained": os.path.join("data", "pretrained"),
"hifigan": os.path.join("data", "hifigan"),
"results": os.path.join("data", "results"),
"languages": os.path.join("data", "languages"),
}
for path in paths.values():
os.makedirs(path, exist_ok=True)
return paths
def cleanup_mei():
"""
Rudimentary workaround for https://github.com/pyinstaller/pyinstaller/issues/2379
"""
mei_bundle = getattr(sys, "_MEIPASS", False)
if mei_bundle:
dir_mei, current_mei = mei_bundle.split("_MEI")
for file in os.listdir(dir_mei):
if file.startswith("_MEI") and not file.endswith(current_mei):
try:
shutil.rmtree(os.path.join(dir_mei, file))
except PermissionError: # mainly to allow simultaneous pyinstaller instances
pass
paths = load_paths()
static = os.path.join("application", "static")
app = Flask(__name__, template_folder=static, static_folder=static)
socketio = SocketIO(app, async_mode="threading", logger=True, engineio_logger=True, debug=True)
from application.views import * # noqa
if __name__ == "__main__":
cleanup_mei()
check_ffmpeg()
webbrowser.open_new_tab("http://localhost:5000")
socketio.run(app)