Files
Voice-Cloning-App/main.py

53 lines
1.6 KiB
Python
Raw Normal View History

2021-03-10 15:56:40 +00:00
import os
2021-05-01 15:49:25 +01:00
import sys
import shutil
2021-03-10 15:56:40 +00:00
import webbrowser
2021-06-04 22:53:03 +01:00
from engineio.async_drivers import threading # noqa
2021-03-10 15:56:40 +00:00
from flask_socketio import SocketIO
from flask import Flask
2021-03-18 16:54:52 +00:00
from application.check_ffmpeg import check_ffmpeg
2021-03-10 15:56:40 +00:00
def load_paths():
paths = {
"datasets": os.path.join("data", "datasets"),
"models": os.path.join("data", "models"),
2021-03-22 21:05:33 +00:00
"pretrained": os.path.join("data", "pretrained"),
2021-04-24 16:06:12 +01:00
"hifigan": os.path.join("data", "hifigan"),
2021-03-18 12:27:38 +00:00
"results": os.path.join("data", "results"),
2021-06-03 19:57:18 +01:00
"languages": os.path.join("data", "languages"),
2021-03-10 15:56:40 +00:00
}
for path in paths.values():
os.makedirs(path, exist_ok=True)
return paths
2021-05-01 15:49:25 +01:00
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
2021-03-10 15:56:40 +00:00
paths = load_paths()
2021-03-18 12:27:38 +00:00
static = os.path.join("application", "static")
app = Flask(__name__, template_folder=static, static_folder=static)
2021-03-10 15:56:40 +00:00
socketio = SocketIO(app, async_mode="threading", logger=True, engineio_logger=True, debug=True)
2021-06-04 22:53:03 +01:00
from application.views import * # noqa
2021-03-10 15:56:40 +00:00
if __name__ == "__main__":
2021-05-01 15:49:25 +01:00
cleanup_mei()
2021-03-18 16:53:04 +00:00
check_ffmpeg()
2021-03-10 15:56:40 +00:00
webbrowser.open_new_tab("http://localhost:5000")
socketio.run(app)