-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathchoose_VITS_model.py
188 lines (168 loc) · 8.64 KB
/
choose_VITS_model.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'choose_VITS_model.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import sys
import json
from PyQt5 import QtCore, QtGui, QtWidgets
import real_basic_UI
import use_main
Ativate = False
class Ui_Dialog(object):
def __init__(self,choose_it):
self.Choose_VITS_model = choose_it
self.path_model = ''
self.path_json = ''
def setupUi(self):
self.Choose_VITS_model.setObjectName("Dialog")
self.Choose_VITS_model.resize(393, 294)
self.Choose_VITS_model.setFixedSize(393, 294)
self.buttonBox = QtWidgets.QDialogButtonBox(self.Choose_VITS_model)
self.buttonBox.setGeometry(QtCore.QRect(30, 240, 341, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.label = QtWidgets.QLabel(self.Choose_VITS_model)
self.label.setGeometry(QtCore.QRect(20, 20, 72, 15))
self.label.setObjectName("label")
self.radioButton = QtWidgets.QRadioButton(self.Choose_VITS_model)
self.radioButton.setGeometry(QtCore.QRect(110, 20, 115, 19))
self.radioButton.setObjectName("radioButton")
#self.radioButton.clicked.connect(self.single_checked)
self.radioButton_2 = QtWidgets.QRadioButton(self.Choose_VITS_model)
self.radioButton_2.setGeometry(QtCore.QRect(220, 20, 115, 19))
self.radioButton_2.setObjectName("radioButton_2")
#self.radioButton_2.clicked.connect(self.multy_checked)
self.label_2 = QtWidgets.QLabel(self.Choose_VITS_model)
self.label_2.setGeometry(QtCore.QRect(20, 60, 300, 16))
self.label_2.setObjectName("label_2")
self.lineEdit = QtWidgets.QLineEdit(self.Choose_VITS_model)
self.lineEdit.setGeometry(QtCore.QRect(20, 90, 291, 21))
self.lineEdit.setObjectName("lineEdit")
self.pushButton = QtWidgets.QPushButton(self.Choose_VITS_model)
self.pushButton.setGeometry(QtCore.QRect(320, 90, 41, 21))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.checked_push_buttom_1)
self.pushButton_2 = QtWidgets.QPushButton(self.Choose_VITS_model)
self.pushButton_2.setGeometry(QtCore.QRect(320, 160, 41, 21))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_2.clicked.connect(self.checked_push_buttom_2)
self.lineEdit_2 = QtWidgets.QLineEdit(self.Choose_VITS_model)
self.lineEdit_2.setGeometry(QtCore.QRect(20, 160, 291, 21))
self.lineEdit_2.setObjectName("lineEdit_2")
self.label_3 = QtWidgets.QLabel(self.Choose_VITS_model)
self.label_3.setGeometry(QtCore.QRect(20, 130, 300, 16))
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(self.Choose_VITS_model)
self.label_4.setGeometry(QtCore.QRect(30, 200, 72, 21))
self.label_4.setObjectName("label_4")
self.comboBox = QtWidgets.QComboBox(self.Choose_VITS_model)
self.comboBox.setGeometry(QtCore.QRect(130, 200, 87, 22))
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem('请选择')
self.retranslateUi()
self.buttonBox.accepted.connect(self.buttonBox_accept)
self.buttonBox.rejected.connect(self.Choose_VITS_model.reject)
QtCore.QMetaObject.connectSlotsByName(self.Choose_VITS_model)
def retranslateUi(self):
_translate = QtCore.QCoreApplication.translate
self.Choose_VITS_model.setWindowTitle(_translate("Dialog", "选择VITS模型"))
self.label.setText(_translate("Dialog", "模型类型:"))
self.radioButton.setText(_translate("Dialog", "单人"))
self.radioButton_2.setText(_translate("Dialog", "多人"))
self.label_2.setText(_translate("Dialog", "模型路径:"))
self.pushButton.setText(_translate("Dialog", "..."))
self.pushButton_2.setText(_translate("Dialog", "..."))
self.label_3.setText(_translate("Dialog", "模型配置文件路径:"))
self.label_4.setText(_translate("Dialog", "说话人"))
self.radioButton.setChecked(False)
self.radioButton_2.setChecked(False)
'''
def single_checked(self):
print('1被点击')
print(self.radioButton.isChecked())
print(self.radioButton_2.isChecked())
if self.radioButton.isChecked() == True:
pass
else:
print('True')
self.radioButton.setChecked(True)
self.radioButton_2.setChecked(False)
def multy_checked(self):
print('2被点击')
print(self.radioButton.isChecked())
print(self.radioButton_2.isChecked())
if self.radioButton_2.isChecked() == True:
pass
else:
print('True')
self.radioButton_2.setChecked(True)
self.radioButton.setChecked(False)
'''
def comboBox_activated(self): #执行使得combobox激活
if self.radioButton_2.isChecked() == True and self.path_json != '':
config = json.load(open(self.path_json,'r'))
print(config['speakers'])
self.speaker = config['speakers']
self.comboBox.addItems(self.speaker)
global Ativate
Ativate = True
def checked_push_buttom_1(self):
path = QtWidgets.QFileDialog.getOpenFileNames()
if path[0][0][-4:] == '.pth' or path[0][0][-4:] == '.PTH':
self.lineEdit.setText(path[0][0])
self.path_model = self.lineEdit.text()
else:
self.label_2.setText('模型路径:(需要.pth文件)')
def checked_push_buttom_2(self):
path = QtWidgets.QFileDialog.getOpenFileNames()
if path[0][0][-5:] == '.json' or path[0][0][-5:] == '.JSON':
self.lineEdit_2.setText(path[0][0])
self.path_json = self.lineEdit_2.text()
else:
self.label_3.setText('模型配置文件路径:(需要.json文件)')
def buttonBox_accept(self):
global Ativate
if self.radioButton.isChecked() ^ self.radioButton_2.isChecked() == False: #^为异或
self.Choose_VITS_model.setWindowTitle("选择VITS模型(未勾选模型类型)")
elif self.lineEdit.text() == '':
self.label_2.setText('模型路径:(需要.pth文件)')
elif self.lineEdit_2.text() == '':
self.label_3.setText('模型配置文件路径:(需要.json文件)')
elif self.radioButton_2.isChecked() == True and self.path_json != '' and self.comboBox.currentText() == '请选择':
if Ativate == False:
self.comboBox_activated()
self.Choose_VITS_model.setWindowTitle("选择VITS模型(未选择说话人)")
else:
pass
else:
Ativate = False
#返回全局变量
if self.radioButton.isChecked() == True:
real_basic_UI.path_of_pth = self.path_model
real_basic_UI.path_of_json = self.path_json
real_basic_UI.model_type = 0
elif self.radioButton_2.isChecked() == True:
real_basic_UI.path_of_pth = self.path_model
real_basic_UI.path_of_json = self.path_json
real_basic_UI.speaker = self.comboBox.currentText()
real_basic_UI.speaker_index = self.speaker.index(self.comboBox.currentText())
real_basic_UI.model_type = 1
#定义VITTS_Class类,并改变其存在状态
if real_basic_UI.model_type == 0:
real_basic_UI.VITS_Class = use_main.single_speaker_model(path_of_pth=real_basic_UI.path_of_pth,path_of_json=real_basic_UI.path_of_json)
real_basic_UI.VITS_CLASS_EXIST =True
elif real_basic_UI.model_type == 1:
real_basic_UI.VITS_Class = use_main.multy_speaker_model(path_of_pth=real_basic_UI.path_of_pth,path_of_json=real_basic_UI.path_of_json)
real_basic_UI.VITS_CLASS_EXIST = True
self.Choose_VITS_model.reject()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
choosel_VITS = QtWidgets.QDialog()
Widget_choose_VITS = Ui_Dialog(choosel_VITS)
Widget_choose_VITS.setupUi()
Widget_choose_VITS.Choose_VITS_model.show()
app.exec()