olivebot/main.py

53 lines
1.2 KiB
Python
Raw Normal View History

2022-06-20 11:05:10 +08:00
import os
import sys
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
from scheduler.thread_manager import MyThread
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'):
if file_name.startswith('sample-') and file_name.endswith('.wav'):
2022-06-20 11:05:10 +08:00
os.remove('./samples/' + file_name)
def __clear_songs():
if not os.path.exists("./songs"):
os.mkdir("./songs")
for file_name in os.listdir('./songs'):
if file_name.endswith('.wav'):
os.remove('./songs/' + file_name)
2022-06-20 11:05:10 +08:00
if __name__ == '__main__':
__clear_samples()
__clear_songs()
2022-06-20 11:05:10 +08:00
config_util.load_config()
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()
ali_nls.start()
flask_server.start()
app = QApplication(sys.argv)
app.setWindowIcon(QtGui.QIcon('icon.png'))
win = MainWindow()
win.show()
app.exit(app.exec_())