2022-06-20 11:05:10 +08:00
|
|
|
|
import os
|
|
|
|
|
import sys
|
2023-01-31 12:40:36 +08:00
|
|
|
|
from io import BytesIO
|
2022-06-20 11:05:10 +08:00
|
|
|
|
|
|
|
|
|
from PyQt5 import QtGui
|
|
|
|
|
from PyQt5.QtWidgets import QApplication
|
|
|
|
|
|
|
|
|
|
from ai_module import ali_nls
|
|
|
|
|
from core import wsa_server
|
|
|
|
|
from gui import flask_server
|
|
|
|
|
from gui.window import MainWindow
|
|
|
|
|
from utils import config_util
|
2023-01-31 12:40:36 +08:00
|
|
|
|
from scheduler.thread_manager import MyThread
|
2023-05-12 18:56:36 +08:00
|
|
|
|
from core.content_db import Content_Db
|
2023-06-14 20:34:36 +08:00
|
|
|
|
import sys
|
|
|
|
|
sys.setrecursionlimit(sys.getrecursionlimit() * 5)
|
2022-06-20 11:05:10 +08:00
|
|
|
|
|
|
|
|
|
def __clear_samples():
|
|
|
|
|
if not os.path.exists("./samples"):
|
|
|
|
|
os.mkdir("./samples")
|
|
|
|
|
for file_name in os.listdir('./samples'):
|
2023-08-04 19:13:28 +08:00
|
|
|
|
if file_name.startswith('sample-'):
|
2022-06-20 11:05:10 +08:00
|
|
|
|
os.remove('./samples/' + file_name)
|
|
|
|
|
|
|
|
|
|
|
2023-01-31 12:40:36 +08:00
|
|
|
|
def __clear_songs():
|
|
|
|
|
if not os.path.exists("./songs"):
|
|
|
|
|
os.mkdir("./songs")
|
|
|
|
|
for file_name in os.listdir('./songs'):
|
2023-03-15 02:22:50 +08:00
|
|
|
|
if file_name.endswith('.mp3'):
|
2023-01-31 12:40:36 +08:00
|
|
|
|
os.remove('./songs/' + file_name)
|
|
|
|
|
|
2023-08-16 19:19:17 +08:00
|
|
|
|
def __clear_logs():
|
|
|
|
|
if not os.path.exists("./logs"):
|
|
|
|
|
os.mkdir("./logs")
|
|
|
|
|
for file_name in os.listdir('./logs'):
|
|
|
|
|
if file_name.endswith('.log'):
|
|
|
|
|
os.remove('./logs/' + file_name)
|
|
|
|
|
|
|
|
|
|
|
2023-01-31 12:40:36 +08:00
|
|
|
|
|
2022-06-20 11:05:10 +08:00
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
__clear_samples()
|
2023-01-31 12:40:36 +08:00
|
|
|
|
__clear_songs()
|
2023-08-16 19:19:17 +08:00
|
|
|
|
__clear_logs()
|
2022-06-20 11:05:10 +08:00
|
|
|
|
config_util.load_config()
|
2023-05-12 18:56:36 +08:00
|
|
|
|
dbstatus = os.path.exists("fay.db")
|
|
|
|
|
if(dbstatus == False):
|
|
|
|
|
contentdb = Content_Db()
|
|
|
|
|
contentdb.init_db()
|
2022-06-20 11:05:10 +08:00
|
|
|
|
ws_server = wsa_server.new_instance(port=10002)
|
|
|
|
|
ws_server.start_server()
|
|
|
|
|
web_ws_server = wsa_server.new_web_instance(port=10003)
|
|
|
|
|
web_ws_server.start_server()
|
2023-05-27 17:03:43 +08:00
|
|
|
|
#Edit by xszyou in 20230516:增加本地asr后,aliyun调成可选配置
|
2023-07-19 22:45:03 +08:00
|
|
|
|
if config_util.ASR_mode == "ali":
|
2023-05-17 18:38:47 +08:00
|
|
|
|
ali_nls.start()
|
2022-06-20 11:05:10 +08:00
|
|
|
|
flask_server.start()
|
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
|
app.setWindowIcon(QtGui.QIcon('icon.png'))
|
|
|
|
|
win = MainWindow()
|
|
|
|
|
win.show()
|
|
|
|
|
app.exit(app.exec_())
|
2023-01-31 12:40:36 +08:00
|
|
|
|
|
|
|
|
|
|