|
|
|
@ -335,41 +335,42 @@ class UI(QDialog):
|
|
|
|
|
return self.convertor_box.itemData(self.convertor_box.currentIndex())
|
|
|
|
|
|
|
|
|
|
def populate_models(self, encoder_models_dir: Path, synthesizer_models_dir: Path,
|
|
|
|
|
vocoder_models_dir: Path, extractor_models_dir: Path, convertor_models_dir: Path):
|
|
|
|
|
vocoder_models_dir: Path, extractor_models_dir: Path, convertor_models_dir: Path, vc_mode: bool):
|
|
|
|
|
# Encoder
|
|
|
|
|
encoder_fpaths = list(encoder_models_dir.glob("*.pt"))
|
|
|
|
|
if len(encoder_fpaths) == 0:
|
|
|
|
|
raise Exception("No encoder models found in %s" % encoder_models_dir)
|
|
|
|
|
self.repopulate_box(self.encoder_box, [(f.stem, f) for f in encoder_fpaths])
|
|
|
|
|
|
|
|
|
|
# Synthesizer
|
|
|
|
|
synthesizer_fpaths = list(synthesizer_models_dir.glob("**/*.pt"))
|
|
|
|
|
if len(synthesizer_fpaths) == 0:
|
|
|
|
|
raise Exception("No synthesizer models found in %s" % synthesizer_models_dir)
|
|
|
|
|
self.repopulate_box(self.synthesizer_box, [(f.stem, f) for f in synthesizer_fpaths])
|
|
|
|
|
if vc_mode:
|
|
|
|
|
# Extractor
|
|
|
|
|
extractor_fpaths = list(extractor_models_dir.glob("*.pt"))
|
|
|
|
|
if len(extractor_fpaths) == 0:
|
|
|
|
|
self.log("No extractor models found in %s" % extractor_fpaths)
|
|
|
|
|
self.repopulate_box(self.extractor_box, [(f.stem, f) for f in extractor_fpaths])
|
|
|
|
|
|
|
|
|
|
# Convertor
|
|
|
|
|
convertor_fpaths = list(convertor_models_dir.glob("*.pth"))
|
|
|
|
|
if len(convertor_fpaths) == 0:
|
|
|
|
|
self.log("No convertor models found in %s" % convertor_fpaths)
|
|
|
|
|
self.repopulate_box(self.convertor_box, [(f.stem, f) for f in convertor_fpaths])
|
|
|
|
|
else:
|
|
|
|
|
# Synthesizer
|
|
|
|
|
synthesizer_fpaths = list(synthesizer_models_dir.glob("**/*.pt"))
|
|
|
|
|
if len(synthesizer_fpaths) == 0:
|
|
|
|
|
raise Exception("No synthesizer models found in %s" % synthesizer_models_dir)
|
|
|
|
|
self.repopulate_box(self.synthesizer_box, [(f.stem, f) for f in synthesizer_fpaths])
|
|
|
|
|
|
|
|
|
|
# Vocoder
|
|
|
|
|
vocoder_fpaths = list(vocoder_models_dir.glob("**/*.pt"))
|
|
|
|
|
vocoder_items = [(f.stem, f) for f in vocoder_fpaths] + [("Griffin-Lim", None)]
|
|
|
|
|
self.repopulate_box(self.vocoder_box, vocoder_items)
|
|
|
|
|
|
|
|
|
|
# Extractor
|
|
|
|
|
extractor_fpaths = list(extractor_models_dir.glob("*.pt"))
|
|
|
|
|
if len(extractor_fpaths) == 0:
|
|
|
|
|
self.log("No extractor models found in %s" % extractor_fpaths)
|
|
|
|
|
self.repopulate_box(self.extractor_box, [(f.stem, f) for f in extractor_fpaths])
|
|
|
|
|
|
|
|
|
|
# Convertor
|
|
|
|
|
convertor_fpaths = list(convertor_models_dir.glob("*.pth"))
|
|
|
|
|
if len(convertor_fpaths) == 0:
|
|
|
|
|
self.log("No convertor models found in %s" % convertor_fpaths)
|
|
|
|
|
self.repopulate_box(self.convertor_box, [(f.stem, f) for f in convertor_fpaths])
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def selected_utterance(self):
|
|
|
|
|
return self.utterance_history.itemData(self.utterance_history.currentIndex())
|
|
|
|
|
|
|
|
|
|
def register_utterance(self, utterance: Utterance):
|
|
|
|
|
def register_utterance(self, utterance: Utterance, vc_mode):
|
|
|
|
|
self.utterance_history.blockSignals(True)
|
|
|
|
|
self.utterance_history.insertItem(0, utterance.name, utterance)
|
|
|
|
|
self.utterance_history.setCurrentIndex(0)
|
|
|
|
@ -379,8 +380,11 @@ class UI(QDialog):
|
|
|
|
|
self.utterance_history.removeItem(self.max_saved_utterances)
|
|
|
|
|
|
|
|
|
|
self.play_button.setDisabled(False)
|
|
|
|
|
self.generate_button.setDisabled(False)
|
|
|
|
|
self.synthesize_button.setDisabled(False)
|
|
|
|
|
if vc_mode:
|
|
|
|
|
self.convert_button.setDisabled(False)
|
|
|
|
|
else:
|
|
|
|
|
self.generate_button.setDisabled(False)
|
|
|
|
|
self.synthesize_button.setDisabled(False)
|
|
|
|
|
|
|
|
|
|
def log(self, line, mode="newline"):
|
|
|
|
|
if mode == "newline":
|
|
|
|
@ -422,7 +426,7 @@ class UI(QDialog):
|
|
|
|
|
else:
|
|
|
|
|
self.seed_textbox.setEnabled(False)
|
|
|
|
|
|
|
|
|
|
def reset_interface(self):
|
|
|
|
|
def reset_interface(self, vc_mode):
|
|
|
|
|
self.draw_embed(None, None, "current")
|
|
|
|
|
self.draw_embed(None, None, "generated")
|
|
|
|
|
self.draw_spec(None, "current")
|
|
|
|
@ -430,14 +434,17 @@ class UI(QDialog):
|
|
|
|
|
self.draw_umap_projections(set())
|
|
|
|
|
self.set_loading(0)
|
|
|
|
|
self.play_button.setDisabled(True)
|
|
|
|
|
self.generate_button.setDisabled(True)
|
|
|
|
|
self.synthesize_button.setDisabled(True)
|
|
|
|
|
if vc_mode:
|
|
|
|
|
self.convert_button.setDisabled(True)
|
|
|
|
|
else:
|
|
|
|
|
self.generate_button.setDisabled(True)
|
|
|
|
|
self.synthesize_button.setDisabled(True)
|
|
|
|
|
self.vocode_button.setDisabled(True)
|
|
|
|
|
self.replay_wav_button.setDisabled(True)
|
|
|
|
|
self.export_wav_button.setDisabled(True)
|
|
|
|
|
[self.log("") for _ in range(self.max_log_lines)]
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
def __init__(self, vc_mode):
|
|
|
|
|
## Initialize the application
|
|
|
|
|
self.app = QApplication(sys.argv)
|
|
|
|
|
super().__init__(None)
|
|
|
|
@ -530,8 +537,9 @@ class UI(QDialog):
|
|
|
|
|
browser_layout.addWidget(self.play_button, i, 2)
|
|
|
|
|
self.stop_button = QPushButton("Stop(暂停)")
|
|
|
|
|
browser_layout.addWidget(self.stop_button, i, 3)
|
|
|
|
|
self.load_soruce_button = QPushButton("Select(选择为被转换的语音输入)")
|
|
|
|
|
browser_layout.addWidget(self.load_soruce_button, i, 4)
|
|
|
|
|
if vc_mode:
|
|
|
|
|
self.load_soruce_button = QPushButton("Select(选择为被转换的语音输入)")
|
|
|
|
|
browser_layout.addWidget(self.load_soruce_button, i, 4)
|
|
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
|
model_groupbox = QGroupBox('Models(模型选择)')
|
|
|
|
@ -544,19 +552,20 @@ class UI(QDialog):
|
|
|
|
|
model_layout.addWidget(QLabel("Encoder:"))
|
|
|
|
|
model_layout.addWidget(self.encoder_box)
|
|
|
|
|
self.synthesizer_box = QComboBox()
|
|
|
|
|
model_layout.addWidget(QLabel("Synthesizer:"))
|
|
|
|
|
model_layout.addWidget(self.synthesizer_box)
|
|
|
|
|
if vc_mode:
|
|
|
|
|
self.extractor_box = QComboBox()
|
|
|
|
|
model_layout.addWidget(QLabel("Extractor:"))
|
|
|
|
|
model_layout.addWidget(self.extractor_box)
|
|
|
|
|
self.convertor_box = QComboBox()
|
|
|
|
|
model_layout.addWidget(QLabel("Convertor:"))
|
|
|
|
|
model_layout.addWidget(self.convertor_box)
|
|
|
|
|
else:
|
|
|
|
|
model_layout.addWidget(QLabel("Synthesizer:"))
|
|
|
|
|
model_layout.addWidget(self.synthesizer_box)
|
|
|
|
|
self.vocoder_box = QComboBox()
|
|
|
|
|
model_layout.addWidget(QLabel("Vocoder:"))
|
|
|
|
|
model_layout.addWidget(self.vocoder_box)
|
|
|
|
|
|
|
|
|
|
self.extractor_box = QComboBox()
|
|
|
|
|
model_layout.addWidget(QLabel("Extractor:"))
|
|
|
|
|
model_layout.addWidget(self.extractor_box)
|
|
|
|
|
self.convertor_box = QComboBox()
|
|
|
|
|
model_layout.addWidget(QLabel("Convertor:"))
|
|
|
|
|
model_layout.addWidget(self.convertor_box)
|
|
|
|
|
|
|
|
|
|
#Replay & Save Audio
|
|
|
|
|
i = 0
|
|
|
|
|
output_layout.addWidget(QLabel("<b>Toolbox Output:</b>"), i, 0)
|
|
|
|
@ -578,7 +587,7 @@ class UI(QDialog):
|
|
|
|
|
|
|
|
|
|
## Embed & spectrograms
|
|
|
|
|
vis_layout.addStretch()
|
|
|
|
|
|
|
|
|
|
# TODO: add spectrograms for source
|
|
|
|
|
gridspec_kw = {"width_ratios": [1, 4]}
|
|
|
|
|
fig, self.current_ax = plt.subplots(1, 2, figsize=(10, 2.25), facecolor="#F0F0F0",
|
|
|
|
|
gridspec_kw=gridspec_kw)
|
|
|
|
@ -599,20 +608,22 @@ class UI(QDialog):
|
|
|
|
|
self.text_prompt = QPlainTextEdit(default_text)
|
|
|
|
|
gen_layout.addWidget(self.text_prompt, stretch=1)
|
|
|
|
|
|
|
|
|
|
self.generate_button = QPushButton("Synthesize and vocode")
|
|
|
|
|
gen_layout.addWidget(self.generate_button)
|
|
|
|
|
|
|
|
|
|
layout = QHBoxLayout()
|
|
|
|
|
self.synthesize_button = QPushButton("Synthesize only")
|
|
|
|
|
layout.addWidget(self.synthesize_button)
|
|
|
|
|
if vc_mode:
|
|
|
|
|
layout = QHBoxLayout()
|
|
|
|
|
self.convert_button = QPushButton("Extract and Convert")
|
|
|
|
|
layout.addWidget(self.convert_button)
|
|
|
|
|
gen_layout.addLayout(layout)
|
|
|
|
|
else:
|
|
|
|
|
self.generate_button = QPushButton("Synthesize and vocode")
|
|
|
|
|
gen_layout.addWidget(self.generate_button)
|
|
|
|
|
layout = QHBoxLayout()
|
|
|
|
|
self.synthesize_button = QPushButton("Synthesize only")
|
|
|
|
|
layout.addWidget(self.synthesize_button)
|
|
|
|
|
|
|
|
|
|
self.vocode_button = QPushButton("Vocode only")
|
|
|
|
|
layout.addWidget(self.vocode_button)
|
|
|
|
|
gen_layout.addLayout(layout)
|
|
|
|
|
|
|
|
|
|
layout = QHBoxLayout()
|
|
|
|
|
self.convert_button = QPushButton("Extract and Convert")
|
|
|
|
|
layout.addWidget(self.convert_button)
|
|
|
|
|
gen_layout.addLayout(layout)
|
|
|
|
|
|
|
|
|
|
layout_seed = QGridLayout()
|
|
|
|
|
self.random_seed_checkbox = QCheckBox("Random seed:")
|
|
|
|
@ -681,7 +692,7 @@ class UI(QDialog):
|
|
|
|
|
self.resize(max_size)
|
|
|
|
|
|
|
|
|
|
## Finalize the display
|
|
|
|
|
self.reset_interface()
|
|
|
|
|
self.reset_interface(vc_mode)
|
|
|
|
|
self.show()
|
|
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
|