From cba914f1d90d2fb2657b69c8c76010b6ffb5f2c1 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Thu, 23 Jun 2022 22:07:19 +0900 Subject: [PATCH 01/10] CLI revamped --- TTS/bin/inquire.py | 235 ++++++++++++++++++++++++++++++++++++++++++++ TTS/utils/manage.py | 22 +++-- 2 files changed, 247 insertions(+), 10 deletions(-) create mode 100644 TTS/bin/inquire.py diff --git a/TTS/bin/inquire.py b/TTS/bin/inquire.py new file mode 100644 index 0000000000..e32f1ded61 --- /dev/null +++ b/TTS/bin/inquire.py @@ -0,0 +1,235 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import argparse +import sys +from argparse import RawTextHelpFormatter + +# pylint: disable=redefined-outer-name, unused-argument +from pathlib import Path + +from TTS.utils.manage import ModelManager +from TTS.utils.synthesizer import Synthesizer + +import inquirer +from inquirer.themes import GreenPassion + +#TODO add inquirer in requirements.txt + +path = Path(__file__).parent / "../.models.json" +manager = ModelManager(path) + + +def official_zoo_inquirer(): + model_list=manager.list_models(print_list=False) + model_list['vocoder_models'].append('default_vocoder') + model_load_questions = [ + inquirer.List('tts_choose', + message="Choose a tts model to load", + choices=model_list['tts_models'], + default="tts_models/en/ljspeech/tacotron2-DDC" + ), + inquirer.List('vocoder_choose', + message="Choose a vocoder model to load", + choices=model_list['vocoder_models'], + ) + ] + answers_model_load = inquirer.prompt(model_load_questions, theme=GreenPassion()) + return answers_model_load + +def multispeaker_inquirer(): + multispeaker_questions = [ + inquirer.Text('speaker_idx', + message="Enter speaker idx", + default=None + ), + inquirer.Text('language_idx', + message="Enter language idx", + default=None + ), + inquirer.Text('speaker_wav', + message="Enter speaker wav file path", + default="Enter some text." + ), + inquirer.Text('reference_wav', + message="Enter ref wav file path", + default=None + ), + inquirer.Text('reference_speaker_idx', + message="Enter reference speaker idx", + default=None + ), + ] + answers_multispeaker = inquirer.prompt(multispeaker_questions, theme=GreenPassion()) + return answers_multispeaker + +def capacitron_inquirer(): + capacitron_questions = [ + inquirer.Text('capacitron_style_wav', + message="Enter capacitron style wav path", + default=None + ), + inquirer.Text('capacitron_style_text', + message="Enter capacitron style text", + default=None + ), + ] + answers_capacitron = inquirer.prompt(capacitron_questions, theme=GreenPassion()) + return answers_capacitron + +def continue_inquirer(): + continue_questions = [ + inquirer.List('to_do', + message="What to do next?", + choices=[ + 'continue new text', + 'restart tts', + 'exit tts' + ] + ), + ] + + continue_answers = inquirer.prompt(continue_questions, theme=GreenPassion()) + return continue_answers + +def tts_inquirer( + synthesizer, + text, + speaker_idx, + language_idx, + speaker_wav, + reference_wav, + reference_speaker_idx, + capacitron_style_wav, + capacitron_style_text +): + tts_questions = [ + inquirer.Text('text_input', + message="Type text to convert to speech", + ), + inquirer.Text('out_path', + message="Enter output wav path", + default="tts_output.wav" + ), + ] + answers_tts = inquirer.prompt(tts_questions, theme=GreenPassion()) + text = answers_tts['text_input'] + outpath = answers_tts['out_path'] + print(f" > Text: {text}") + # kick it + wav = synthesizer.tts( + text, + speaker_idx, + language_idx, + speaker_wav, + reference_wav=reference_wav, + reference_speaker_name=reference_speaker_idx, + style_wav=capacitron_style_wav, + style_text=capacitron_style_text, + ) + + # save the results + print(f" > Saving output to {outpath}") + synthesizer.save_wav(wav, outpath) + + continue_answers=continue_inquirer() + return continue_answers + +def init_prompt(): + model_path=None + config_path=None + speakers_file_path=None + language_ids_file_path=None + vocoder_path=None + vocoder_config_path=None + encoder_path=None + encoder_config_path=None + use_cuda=True + + text="Random Text." + speaker_idx=None + language_idx=None + speaker_wav=None + reference_wav=reference_wav=None + reference_speaker_idx=reference_speaker_name=None + capacitron_style_wav=style_wav=None + capacitron_style_text=style_text=None + + questions = [ + inquirer.List('to_do', + message="What do you need?", + choices=[ + 'play with your own model', + 'play with official model zoo', + 'exit tts' + ] + ), + ] + + answers = inquirer.prompt(questions, theme=GreenPassion()) + + if answers['to_do'] == 'exit tts': + return + + if answers['to_do'] == 'play with official model zoo': + answers_model_load = official_zoo_inquirer() + tts_model_name=answers_model_load['tts_choose'] + model_path, config_path, model_item = manager.download_model(tts_model_name) + vocoder_name=answers_model_load['vocoder_choose'] if answers_model_load['vocoder_choose'] != "default_vocoder" else model_item["default_vocoder"] + vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name) + + synthesizer = Synthesizer( + model_path, + config_path, + speakers_file_path, + language_ids_file_path, + vocoder_path, + vocoder_config_path, + encoder_path, + encoder_config_path, + use_cuda, + ) + + if synthesizer.tts_speakers_file: + answers_multispeaker=multispeaker_inquirer() + speaker_idx=answers_multispeaker['speaker_idx'], + language_idx=answers_multispeaker['language_idx'], + speaker_wav=answers_multispeaker['speaker_wav'], + reference_wav=reference_wav=answers_multispeaker['reference_wav'], + reference_speaker_idx=answers_multispeaker['reference_speaker_idx'], + + if 'capacitron' in tts_model_name: + answers_capacitron = capacitron_inquirer() + capacitron_style_wav=answers_capacitron['capacitron_style_wav'], + capacitron_style_text=answers_capacitron['capacitron_style_text'], + + continue_answers = tts_inquirer( + synthesizer, + text, + speaker_idx, + language_idx, + speaker_wav, + reference_wav, + reference_speaker_idx, + capacitron_style_wav, + capacitron_style_text + ) + if continue_answers['to_do'] == 'exit tts': + return + if continue_answers['to_do'] == 'restart tts': + init_prompt() + if continue_answers['to_do'] == 'continue new text': + tts_inquirer( + synthesizer, + text, + speaker_idx, + language_idx, + speaker_wav, + reference_wav, + reference_speaker_idx, + capacitron_style_wav, + capacitron_style_text + ) + + +init_prompt() \ No newline at end of file diff --git a/TTS/utils/manage.py b/TTS/utils/manage.py index 281e5af02a..44fe52f5d0 100644 --- a/TTS/utils/manage.py +++ b/TTS/utils/manage.py @@ -58,17 +58,18 @@ def read_models_file(self, file_path): with open(file_path, "r", encoding="utf-8") as json_file: self.models_dict = json.load(json_file) - def _list_models(self, model_type, model_count=0): + def _list_models(self, model_type, model_count=0, print_list=False): model_list = [] for lang in self.models_dict[model_type]: for dataset in self.models_dict[model_type][lang]: for model in self.models_dict[model_type][lang][dataset]: model_full_name = f"{model_type}--{lang}--{dataset}--{model}" output_path = os.path.join(self.output_prefix, model_full_name) - if os.path.exists(output_path): - print(f" {model_count}: {model_type}/{lang}/{dataset}/{model} [already downloaded]") - else: - print(f" {model_count}: {model_type}/{lang}/{dataset}/{model}") + if print_list: + if os.path.exists(output_path): + print(f" {model_count}: {model_type}/{lang}/{dataset}/{model} [already downloaded]") + else: + print(f" {model_count}: {model_type}/{lang}/{dataset}/{model}") model_list.append(f"{model_type}/{lang}/{dataset}/{model}") model_count += 1 return model_list @@ -81,13 +82,14 @@ def _list_for_model_type(self, model_type): models_name_list.extend(self._list_models(model_type, model_count)) return [name.replace(model_type + "/", "") for name in models_name_list] - def list_models(self): - print(" Name format: type/language/dataset/model") - models_name_list = [] + def list_models(self, print_list=True): + if print_list: + print(" Name format: type/language/dataset/model") + models_name_list = {} model_count = 1 for model_type in self.models_dict: - model_list = self._list_models(model_type, model_count) - models_name_list.extend(model_list) + model_list = self._list_models(model_type, model_count, print_list=print_list) + models_name_list[model_type]=model_list return models_name_list def model_info_by_idx(self, model_query): From 577ba7d2b9907e6175dd197317d4a0df50eb8038 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Fri, 24 Jun 2022 01:09:38 +0900 Subject: [PATCH 02/10] CLI revamped using inquirer --- TTS/bin/inquire.py | 175 +++++++++++++++++++++++++++++---------------- requirements.txt | 4 +- 2 files changed, 115 insertions(+), 64 deletions(-) diff --git a/TTS/bin/inquire.py b/TTS/bin/inquire.py index e32f1ded61..645c34c9f4 100644 --- a/TTS/bin/inquire.py +++ b/TTS/bin/inquire.py @@ -19,11 +19,17 @@ path = Path(__file__).parent / "../.models.json" manager = ModelManager(path) +str2none = lambda i : i or None #converter for default None (''->None) def official_zoo_inquirer(): model_list=manager.list_models(print_list=False) model_list['vocoder_models'].append('default_vocoder') model_load_questions = [ + inquirer.List('use_cuda', + message="Run model on CUDA?", + choices=[True,False], + default=False, + ), inquirer.List('tts_choose', message="Choose a tts model to load", choices=model_list['tts_models'], @@ -37,8 +43,51 @@ def official_zoo_inquirer(): answers_model_load = inquirer.prompt(model_load_questions, theme=GreenPassion()) return answers_model_load +def custom_model_inquirer(): + custom_model_load_questions = [ + inquirer.List('use_cuda', + message="Run model on CUDA?", + choices=[True,False], + default=False, + ), + inquirer.Text('model_path', + message="Path to TTS model path", + default=None, + ), + inquirer.Text('model_config_path', + message="Path to TTS model config path", + default=None, + ), + inquirer.Text('vocoder_path', + message="Path to vocoder model file.", + default=None, + ), + inquirer.Text('vocoder_config_path', + message="Path to vocoder model config file.", + default=None, + ), + inquirer.Text('encoder_path', + message="Path to speaker encoder model file.", + default=None, + ), + inquirer.Text('encoder_config_path', + message="Path to speaker encoder config file.", + default=None, + ), + ] + answers_custom_model_load = inquirer.prompt(custom_model_load_questions, theme=GreenPassion()) + return answers_custom_model_load + def multispeaker_inquirer(): multispeaker_questions = [ + inquirer.Text('speakers_file_path', + message="JSON file for multi-speaker model.", + default=None, + ), + inquirer.Text('language_ids_file_path', + message="JSON file for multi-lingual model.", + default=None, + ), inquirer.Text('speaker_idx', message="Enter speaker idx", default=None @@ -49,7 +98,7 @@ def multispeaker_inquirer(): ), inquirer.Text('speaker_wav', message="Enter speaker wav file path", - default="Enter some text." + default=None ), inquirer.Text('reference_wav', message="Enter ref wav file path", @@ -94,7 +143,6 @@ def continue_inquirer(): def tts_inquirer( synthesizer, - text, speaker_idx, language_idx, speaker_wav, @@ -113,8 +161,9 @@ def tts_inquirer( ), ] answers_tts = inquirer.prompt(tts_questions, theme=GreenPassion()) - text = answers_tts['text_input'] + text = str2none(answers_tts['text_input']) outpath = answers_tts['out_path'] + text = text if text is not None else "Enter random text." print(f" > Text: {text}") # kick it wav = synthesizer.tts( @@ -135,6 +184,50 @@ def tts_inquirer( continue_answers=continue_inquirer() return continue_answers +def block_prompt(synthesizer, tts_model_name): + speaker_idx=None + language_idx=None + speaker_wav=None + reference_wav=reference_wav=None + reference_speaker_idx=None + capacitron_style_wav=None + capacitron_style_text=None + + if synthesizer.tts_speakers_file or hasattr(synthesizer.tts_model.speaker_manager, "ids"): + answers_multispeaker=multispeaker_inquirer() + for key,item in answers_multispeaker.items(): + answers_multispeaker[key]=str2none(item) + speaker_idx=answers_multispeaker['speaker_idx'] + language_idx=answers_multispeaker['language_idx'] + speaker_wav=answers_multispeaker['speaker_wav'] + reference_wav=reference_wav=answers_multispeaker['reference_wav'] + reference_speaker_idx=answers_multispeaker['reference_speaker_idx'] + + if 'capacitron' in tts_model_name: + answers_capacitron = capacitron_inquirer() + for key,item in answers_capacitron.items(): + answers_capacitron[key]=str2none(item) + capacitron_style_wav=answers_capacitron['capacitron_style_wav'] + capacitron_style_text=answers_capacitron['capacitron_style_text'] + + continue_answers = tts_inquirer( + synthesizer, + speaker_idx, + language_idx, + speaker_wav, + reference_wav, + reference_speaker_idx, + capacitron_style_wav, + capacitron_style_text + ) + if continue_answers['to_do'] == 'exit tts': + return + if continue_answers['to_do'] == 'restart tts': + print("restart") + init_prompt() + if continue_answers['to_do'] == 'continue new text': + block_prompt(synthesizer, tts_model_name) + def init_prompt(): model_path=None config_path=None @@ -144,18 +237,9 @@ def init_prompt(): vocoder_config_path=None encoder_path=None encoder_config_path=None - use_cuda=True - - text="Random Text." - speaker_idx=None - language_idx=None - speaker_wav=None - reference_wav=reference_wav=None - reference_speaker_idx=reference_speaker_name=None - capacitron_style_wav=style_wav=None - capacitron_style_text=style_text=None - - questions = [ + use_cuda=False + + init_questions = [ inquirer.List('to_do', message="What do you need?", choices=[ @@ -166,18 +250,25 @@ def init_prompt(): ), ] - answers = inquirer.prompt(questions, theme=GreenPassion()) + init_answers = inquirer.prompt(init_questions, theme=GreenPassion()) - if answers['to_do'] == 'exit tts': + if init_answers['to_do'] == 'exit tts': return - if answers['to_do'] == 'play with official model zoo': + if init_answers['to_do'] == 'play with your own model': + answers_custom_model_load = custom_model_inquirer() + + if init_answers['to_do'] == 'play with official model zoo': answers_model_load = official_zoo_inquirer() tts_model_name=answers_model_load['tts_choose'] model_path, config_path, model_item = manager.download_model(tts_model_name) + print(model_item["default_vocoder"]) vocoder_name=answers_model_load['vocoder_choose'] if answers_model_load['vocoder_choose'] != "default_vocoder" else model_item["default_vocoder"] - vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name) - + print(vocoder_name) + if vocoder_name is not None: + vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name) + use_cuda=answers_model_load['use_cuda'] + synthesizer = Synthesizer( model_path, config_path, @@ -189,47 +280,7 @@ def init_prompt(): encoder_config_path, use_cuda, ) - - if synthesizer.tts_speakers_file: - answers_multispeaker=multispeaker_inquirer() - speaker_idx=answers_multispeaker['speaker_idx'], - language_idx=answers_multispeaker['language_idx'], - speaker_wav=answers_multispeaker['speaker_wav'], - reference_wav=reference_wav=answers_multispeaker['reference_wav'], - reference_speaker_idx=answers_multispeaker['reference_speaker_idx'], - - if 'capacitron' in tts_model_name: - answers_capacitron = capacitron_inquirer() - capacitron_style_wav=answers_capacitron['capacitron_style_wav'], - capacitron_style_text=answers_capacitron['capacitron_style_text'], - - continue_answers = tts_inquirer( - synthesizer, - text, - speaker_idx, - language_idx, - speaker_wav, - reference_wav, - reference_speaker_idx, - capacitron_style_wav, - capacitron_style_text - ) - if continue_answers['to_do'] == 'exit tts': - return - if continue_answers['to_do'] == 'restart tts': - init_prompt() - if continue_answers['to_do'] == 'continue new text': - tts_inquirer( - synthesizer, - text, - speaker_idx, - language_idx, - speaker_wav, - reference_wav, - reference_speaker_idx, - capacitron_style_wav, - capacitron_style_text - ) - + block_prompt(synthesizer, tts_model_name) + init_prompt() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index b3acfeca4e..3006efdbdc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ # core deps -numpy==1.21.6 +numpy>=1.21.6 cython==0.29.28 scipy>=1.4.0 torch>=1.7 torchaudio soundfile librosa==0.8.0 -numba==0.55.1 +numba>=0.55.1 inflect tqdm anyascii From c4409951fd320aa3ad5223186f241f828fe6a6a1 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Fri, 24 Jun 2022 12:18:44 +0900 Subject: [PATCH 03/10] tqdm bar for model download progress --- TTS/bin/inquire.py | 11 ++++++++--- TTS/utils/manage.py | 14 ++++++++++++-- requirements.txt | 6 ++++-- setup.py | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/TTS/bin/inquire.py b/TTS/bin/inquire.py index 645c34c9f4..492233f6e2 100644 --- a/TTS/bin/inquire.py +++ b/TTS/bin/inquire.py @@ -23,7 +23,7 @@ def official_zoo_inquirer(): model_list=manager.list_models(print_list=False) - model_list['vocoder_models'].append('default_vocoder') + model_list['vocoder_models'].insert(0,'default_vocoder') model_load_questions = [ inquirer.List('use_cuda', message="Run model on CUDA?", @@ -282,5 +282,10 @@ def init_prompt(): ) block_prompt(synthesizer, tts_model_name) - -init_prompt() \ No newline at end of file + +def main(): + print("welcome to COQUI TTS") + init_prompt() + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/TTS/utils/manage.py b/TTS/utils/manage.py index 44fe52f5d0..3259817e54 100644 --- a/TTS/utils/manage.py +++ b/TTS/utils/manage.py @@ -5,6 +5,7 @@ from pathlib import Path from shutil import copyfile, rmtree from typing import Dict, Tuple +from tqdm import tqdm import requests @@ -339,11 +340,20 @@ def _update_path(field_name, new_path, config_path): def _download_zip_file(file_url, output_folder): """Download the github releases""" # download the file - r = requests.get(file_url) + r = requests.get(file_url, stream=True) # extract the file try: - with zipfile.ZipFile(io.BytesIO(r.content)) as z: + total_size_in_bytes= int(r.headers.get('content-length', 0)) + block_size = 1024 #1 Kibibyte + progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True) + temp_zip_name = os.path.join(output_folder, file_url.split('/')[-1]) + with open(temp_zip_name, 'wb') as file: + for data in r.iter_content(block_size): + progress_bar.update(len(data)) + file.write(data) + with zipfile.ZipFile(temp_zip_name) as z: z.extractall(output_folder) + os.remove(temp_zip_name) #delete zip after extract except zipfile.BadZipFile: print(f" > Error: Bad zip file - {file_url}") raise zipfile.BadZipFile # pylint: disable=raise-missing-from diff --git a/requirements.txt b/requirements.txt index 3006efdbdc..0ac3a18383 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,19 @@ # core deps -numpy>=1.21.6 +numpy==1.22.4 cython==0.29.28 scipy>=1.4.0 torch>=1.7 torchaudio soundfile librosa==0.8.0 -numba>=0.55.1 +numba==0.55.2 inflect tqdm anyascii pyyaml fsspec>=2021.04.0 +#deps for CLI +inquirer # deps for examples flask # deps for inference diff --git a/setup.py b/setup.py index 3c8609499d..81d672ef25 100644 --- a/setup.py +++ b/setup.py @@ -114,7 +114,7 @@ def pip_install(package_name): "notebooks": requirements_notebooks, }, python_requires=">=3.7.0, <3.11", - entry_points={"console_scripts": ["tts=TTS.bin.synthesize:main", "tts-server = TTS.server.server:main"]}, + entry_points={"console_scripts": ["tts=TTS.bin.synthesize:main", "tts-server = TTS.server.server:main", "tts-cli = TTS.bin.inquire:main"]}, classifiers=[ "Programming Language :: Python", "Programming Language :: Python :: 3", From 24ae12ed768bbc7d1e01dc5c4d36c023e6495483 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Fri, 24 Jun 2022 12:38:11 +0900 Subject: [PATCH 04/10] requirements.txt temp --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 0ac3a18383..5cd04ca2d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ # core deps -numpy==1.22.4 +numpy>=1.21.6 cython==0.29.28 scipy>=1.4.0 torch>=1.7 torchaudio soundfile librosa==0.8.0 -numba==0.55.2 +numba>=0.55.1 inflect tqdm anyascii From 12159a9d54916b2ba7afcc610687d2bfbea51a35 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Fri, 24 Jun 2022 13:14:59 +0900 Subject: [PATCH 05/10] use existing _list_for_model_type to stop test breaks --- TTS/bin/inquire.py | 7 ++++++- TTS/utils/manage.py | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/TTS/bin/inquire.py b/TTS/bin/inquire.py index 492233f6e2..e006b9c03b 100644 --- a/TTS/bin/inquire.py +++ b/TTS/bin/inquire.py @@ -22,7 +22,9 @@ str2none = lambda i : i or None #converter for default None (''->None) def official_zoo_inquirer(): - model_list=manager.list_models(print_list=False) + model_list={} + model_list['tts_models']=manager.list_tts_models(print_list=False) + model_list['vocoder_models']=manager.list_vocoder_models(print_list=False) model_list['vocoder_models'].insert(0,'default_vocoder') model_load_questions = [ inquirer.List('use_cuda', @@ -257,6 +259,9 @@ def init_prompt(): if init_answers['to_do'] == 'play with your own model': answers_custom_model_load = custom_model_inquirer() + for key,item in answers_custom_model_load.items(): + answers_custom_model_load[key]=str2none(item) + if init_answers['to_do'] == 'play with official model zoo': answers_model_load = official_zoo_inquirer() diff --git a/TTS/utils/manage.py b/TTS/utils/manage.py index 3259817e54..99a66735f8 100644 --- a/TTS/utils/manage.py +++ b/TTS/utils/manage.py @@ -75,22 +75,22 @@ def _list_models(self, model_type, model_count=0, print_list=False): model_count += 1 return model_list - def _list_for_model_type(self, model_type): - print(" Name format: language/dataset/model") + def _list_for_model_type(self, model_type, print_list=False): + if print_list: + print(" Name format: model_type/language/dataset/model") models_name_list = [] model_count = 1 - model_type = "tts_models" - models_name_list.extend(self._list_models(model_type, model_count)) - return [name.replace(model_type + "/", "") for name in models_name_list] + models_name_list.extend(self._list_models(model_type=model_type, model_count=model_count,print_list=print_list)) + return models_name_list def list_models(self, print_list=True): if print_list: print(" Name format: type/language/dataset/model") - models_name_list = {} + models_name_list = [] model_count = 1 for model_type in self.models_dict: model_list = self._list_models(model_type, model_count, print_list=print_list) - models_name_list[model_type]=model_list + models_name_list.extend(model_list) return models_name_list def model_info_by_idx(self, model_query): @@ -168,17 +168,17 @@ def model_info_by_full_name(self, model_query_name): else: print(f"> model_type {model_type} does not exist in the list.") - def list_tts_models(self): + def list_tts_models(self, print_list=True): """Print all `TTS` models and return a list of model names - Format is `language/dataset/model` + Format is `tts_models/language/dataset/model` """ return self._list_for_model_type("tts_models") - def list_vocoder_models(self): + def list_vocoder_models(self, print_list=True): """Print all the `vocoder` models and return a list of model names - Format is `language/dataset/model` + Format is `vocoder_models/language/dataset/model` """ return self._list_for_model_type("vocoder_models") From 46d093ea083998a8a5843ce8365ee85fce309745 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Fri, 24 Jun 2022 13:47:27 +0900 Subject: [PATCH 06/10] model info --- TTS/bin/frogie.py | 25 +++++++++++++++++++++++++ TTS/bin/inquire.py | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 TTS/bin/frogie.py diff --git a/TTS/bin/frogie.py b/TTS/bin/frogie.py new file mode 100644 index 0000000000..ebd557e28a --- /dev/null +++ b/TTS/bin/frogie.py @@ -0,0 +1,25 @@ +def ascii_art_printer(): + print(r""" + + # ,*++++++*, ,*++++++*, + # *++. .+++ *++. .++* + # *+* ,++++* *+* *+* ,++++, *+* + # ,+, .++++++++++* ,++,,,,*+, ,++++++++++. *+, + # *+. .++++++++++++..++ *+.,++++++++++++. .+* + # .+* ++++++++++++.*+, .+*.++++++++++++ *+, + # .++ *++++++++* ++, .++.*++++++++* ++, + # ,+++*. . .*++, ,++*. .*+++* + # *+, .,*++**. .**++**. ,+* + # .+* *+, + # *+. Coqui .+* + # *+* +++ TTS +++ *+* + # .+++*. . . *+++. + # ,+* *+++*... ...*+++* *+, + # .++. .""""+++++++****+++++++"""". ++. + # ,++. .++, + # .++* *++. + # *+++, ,+++* + # .,*++++::::::++++*,. + # `````` + + """) \ No newline at end of file diff --git a/TTS/bin/inquire.py b/TTS/bin/inquire.py index e006b9c03b..a980aaaaf1 100644 --- a/TTS/bin/inquire.py +++ b/TTS/bin/inquire.py @@ -45,6 +45,17 @@ def official_zoo_inquirer(): answers_model_load = inquirer.prompt(model_load_questions, theme=GreenPassion()) return answers_model_load +def official_zoo_info_inquirer(): + joint_model_list=manager.list_tts_models(print_list=False)+manager.list_vocoder_models(print_list=False) + model_info_questions = [ + inquirer.List('model_choose_for_info', + message="Choose a tts model for info", + choices=joint_model_list, + ), + ] + answers_model_info_request = inquirer.prompt(model_info_questions, theme=GreenPassion()) + return answers_model_info_request + def custom_model_inquirer(): custom_model_load_questions = [ inquirer.List('use_cuda', @@ -133,7 +144,7 @@ def continue_inquirer(): inquirer.List('to_do', message="What to do next?", choices=[ - 'continue new text', + 'try another text-input', 'restart tts', 'exit tts' ] @@ -227,7 +238,7 @@ def block_prompt(synthesizer, tts_model_name): if continue_answers['to_do'] == 'restart tts': print("restart") init_prompt() - if continue_answers['to_do'] == 'continue new text': + if continue_answers['to_do'] == 'try another text-input': block_prompt(synthesizer, tts_model_name) def init_prompt(): @@ -244,9 +255,10 @@ def init_prompt(): init_questions = [ inquirer.List('to_do', message="What do you need?", - choices=[ - 'play with your own model', + choices=[ + 'get info from official model zoo', 'play with official model zoo', + 'play with your own model', 'exit tts' ] ), @@ -254,22 +266,18 @@ def init_prompt(): init_answers = inquirer.prompt(init_questions, theme=GreenPassion()) + if init_answers['to_do'] == 'get info from official model zoo': + answers_model_load = official_zoo_info_inquirer() + manager.model_info_by_full_name(answers_model_load['model_choose_for_info']) + if init_answers['to_do'] == 'exit tts': return - if init_answers['to_do'] == 'play with your own model': - answers_custom_model_load = custom_model_inquirer() - for key,item in answers_custom_model_load.items(): - answers_custom_model_load[key]=str2none(item) - - if init_answers['to_do'] == 'play with official model zoo': answers_model_load = official_zoo_inquirer() tts_model_name=answers_model_load['tts_choose'] model_path, config_path, model_item = manager.download_model(tts_model_name) - print(model_item["default_vocoder"]) vocoder_name=answers_model_load['vocoder_choose'] if answers_model_load['vocoder_choose'] != "default_vocoder" else model_item["default_vocoder"] - print(vocoder_name) if vocoder_name is not None: vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name) use_cuda=answers_model_load['use_cuda'] @@ -288,7 +296,15 @@ def init_prompt(): block_prompt(synthesizer, tts_model_name) + if init_answers['to_do'] == 'play with your own model': + answers_custom_model_load = custom_model_inquirer() + for key,item in answers_custom_model_load.items(): + answers_custom_model_load[key]=str2none(item) + print(answers_custom_model_load) + def main(): + from TTS.bin.frogie import ascii_art_printer + # ascii_art_printer() print("welcome to COQUI TTS") init_prompt() From 1ab28b4f76960d54e03b35c9c5e48c1443388ed1 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Fri, 24 Jun 2022 17:20:28 +0900 Subject: [PATCH 07/10] minor fixes --- TTS/bin/inquire.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/TTS/bin/inquire.py b/TTS/bin/inquire.py index a980aaaaf1..6ba90a2b13 100644 --- a/TTS/bin/inquire.py +++ b/TTS/bin/inquire.py @@ -197,7 +197,7 @@ def tts_inquirer( continue_answers=continue_inquirer() return continue_answers -def block_prompt(synthesizer, tts_model_name): +def block_prompt(synthesizer, isCapacitron=False): speaker_idx=None language_idx=None speaker_wav=None @@ -205,6 +205,7 @@ def block_prompt(synthesizer, tts_model_name): reference_speaker_idx=None capacitron_style_wav=None capacitron_style_text=None + isCapacitron=isCapacitron if synthesizer.tts_speakers_file or hasattr(synthesizer.tts_model.speaker_manager, "ids"): answers_multispeaker=multispeaker_inquirer() @@ -216,7 +217,7 @@ def block_prompt(synthesizer, tts_model_name): reference_wav=reference_wav=answers_multispeaker['reference_wav'] reference_speaker_idx=answers_multispeaker['reference_speaker_idx'] - if 'capacitron' in tts_model_name: + answers_capacitron = capacitron_inquirer() for key,item in answers_capacitron.items(): answers_capacitron[key]=str2none(item) @@ -239,7 +240,7 @@ def block_prompt(synthesizer, tts_model_name): print("restart") init_prompt() if continue_answers['to_do'] == 'try another text-input': - block_prompt(synthesizer, tts_model_name) + block_prompt(synthesizer, isCapacitron=isCapacitron) def init_prompt(): model_path=None @@ -294,7 +295,10 @@ def init_prompt(): use_cuda, ) - block_prompt(synthesizer, tts_model_name) + if 'capacitron' in tts_model_name: + isCapacitron = True + + block_prompt(synthesizer, isCapacitron) if init_answers['to_do'] == 'play with your own model': answers_custom_model_load = custom_model_inquirer() From d5efbc1e58d4b564ce339b80713fd7adf0e30e48 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Fri, 24 Jun 2022 20:35:52 +0900 Subject: [PATCH 08/10] added custom model loader, capacitron check, multi-speaker check --- TTS/bin/frogie.py | 2 +- TTS/bin/inquire.py | 58 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/TTS/bin/frogie.py b/TTS/bin/frogie.py index ebd557e28a..1b92c18391 100644 --- a/TTS/bin/frogie.py +++ b/TTS/bin/frogie.py @@ -15,7 +15,7 @@ def ascii_art_printer(): # *+* +++ TTS +++ *+* # .+++*. . . *+++. # ,+* *+++*... ...*+++* *+, - # .++. .""""+++++++****+++++++"""". ++. + # .++. .---+++++++****+++++++----. ++. # ,++. .++, # .++* *++. # *+++, ,+++* diff --git a/TTS/bin/inquire.py b/TTS/bin/inquire.py index 6ba90a2b13..b5c83656a8 100644 --- a/TTS/bin/inquire.py +++ b/TTS/bin/inquire.py @@ -40,7 +40,12 @@ def official_zoo_inquirer(): inquirer.List('vocoder_choose', message="Choose a vocoder model to load", choices=model_list['vocoder_models'], - ) + ), + inquirer.List('use_cuda', + message="Run model on CUDA?", + choices=[True,False], + default=True, + ), ] answers_model_load = inquirer.prompt(model_load_questions, theme=GreenPassion()) return answers_model_load @@ -58,11 +63,6 @@ def official_zoo_info_inquirer(): def custom_model_inquirer(): custom_model_load_questions = [ - inquirer.List('use_cuda', - message="Run model on CUDA?", - choices=[True,False], - default=False, - ), inquirer.Text('model_path', message="Path to TTS model path", default=None, @@ -86,6 +86,11 @@ def custom_model_inquirer(): inquirer.Text('encoder_config_path', message="Path to speaker encoder config file.", default=None, + ), + inquirer.List('use_cuda', + message="Run model on CUDA?", + choices=[True,False], + default=True, ), ] answers_custom_model_load = inquirer.prompt(custom_model_load_questions, theme=GreenPassion()) @@ -216,14 +221,14 @@ def block_prompt(synthesizer, isCapacitron=False): speaker_wav=answers_multispeaker['speaker_wav'] reference_wav=reference_wav=answers_multispeaker['reference_wav'] reference_speaker_idx=answers_multispeaker['reference_speaker_idx'] - + if isCapacitron: answers_capacitron = capacitron_inquirer() for key,item in answers_capacitron.items(): answers_capacitron[key]=str2none(item) capacitron_style_wav=answers_capacitron['capacitron_style_wav'] capacitron_style_text=answers_capacitron['capacitron_style_text'] - + continue_answers = tts_inquirer( synthesizer, speaker_idx, @@ -234,6 +239,7 @@ def block_prompt(synthesizer, isCapacitron=False): capacitron_style_wav, capacitron_style_text ) + if continue_answers['to_do'] == 'exit tts': return if continue_answers['to_do'] == 'restart tts': @@ -251,8 +257,9 @@ def init_prompt(): vocoder_config_path=None encoder_path=None encoder_config_path=None - use_cuda=False - + use_cuda=True + isCapacitron=False + init_questions = [ inquirer.List('to_do', message="What do you need?", @@ -298,17 +305,42 @@ def init_prompt(): if 'capacitron' in tts_model_name: isCapacitron = True - block_prompt(synthesizer, isCapacitron) + block_prompt(synthesizer, isCapacitron=isCapacitron) if init_answers['to_do'] == 'play with your own model': answers_custom_model_load = custom_model_inquirer() for key,item in answers_custom_model_load.items(): answers_custom_model_load[key]=str2none(item) - print(answers_custom_model_load) + + model_path=answers_custom_model_load['model_path'] + config_path=answers_custom_model_load['model_config_path'] + vocoder_path=answers_custom_model_load['vocoder_path'] + vocoder_config_path=answers_custom_model_load['vocoder_config_path'] + encoder_path=answers_custom_model_load['encoder_path'] + encoder_config_path=answers_custom_model_load['encoder_config_path'] + use_cuda=answers_custom_model_load['use_cuda'] + + synthesizer = Synthesizer( + model_path, + config_path, + speakers_file_path, + language_ids_file_path, + vocoder_path, + vocoder_config_path, + encoder_path, + encoder_config_path, + use_cuda, + ) + + if 'use_capacitron_vae' in synthesizer.tts_config: #find if model is capacitron + print("yes cap") + isCapacitron = True + + block_prompt(synthesizer, isCapacitron=isCapacitron) def main(): from TTS.bin.frogie import ascii_art_printer - # ascii_art_printer() + ascii_art_printer() print("welcome to COQUI TTS") init_prompt() From ddf8427ffec3d597ee7078c17c6cdc82cd60f149 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Fri, 24 Jun 2022 20:39:15 +0900 Subject: [PATCH 09/10] minor fixes --- TTS/bin/inquire.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/TTS/bin/inquire.py b/TTS/bin/inquire.py index b5c83656a8..1bebac7b7f 100644 --- a/TTS/bin/inquire.py +++ b/TTS/bin/inquire.py @@ -27,11 +27,6 @@ def official_zoo_inquirer(): model_list['vocoder_models']=manager.list_vocoder_models(print_list=False) model_list['vocoder_models'].insert(0,'default_vocoder') model_load_questions = [ - inquirer.List('use_cuda', - message="Run model on CUDA?", - choices=[True,False], - default=False, - ), inquirer.List('tts_choose', message="Choose a tts model to load", choices=model_list['tts_models'], From 5e3f254a99922a6c77c18e5fb5a3a94ae9255459 Mon Sep 17 00:00:00 2001 From: p0p4k Date: Fri, 24 Jun 2022 20:46:41 +0900 Subject: [PATCH 10/10] style fix --- TTS/bin/inquire.py | 411 ++++++++++++++++++++++----------------------- 1 file changed, 204 insertions(+), 207 deletions(-) diff --git a/TTS/bin/inquire.py b/TTS/bin/inquire.py index 1bebac7b7f..0a2c182074 100644 --- a/TTS/bin/inquire.py +++ b/TTS/bin/inquire.py @@ -1,10 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import argparse -import sys -from argparse import RawTextHelpFormatter - # pylint: disable=redefined-outer-name, unused-argument from pathlib import Path @@ -14,146 +10,140 @@ import inquirer from inquirer.themes import GreenPassion -#TODO add inquirer in requirements.txt +# TODO add inquirer in requirements.txt path = Path(__file__).parent / "../.models.json" manager = ModelManager(path) -str2none = lambda i : i or None #converter for default None (''->None) +str2none = lambda i: i or None # converter for default None (''->None) + def official_zoo_inquirer(): - model_list={} - model_list['tts_models']=manager.list_tts_models(print_list=False) - model_list['vocoder_models']=manager.list_vocoder_models(print_list=False) - model_list['vocoder_models'].insert(0,'default_vocoder') + model_list = {} + model_list["tts_models"] = manager.list_tts_models(print_list=False) + model_list["vocoder_models"] = manager.list_vocoder_models(print_list=False) + model_list["vocoder_models"].insert(0, "default_vocoder") model_load_questions = [ - inquirer.List('tts_choose', - message="Choose a tts model to load", - choices=model_list['tts_models'], - default="tts_models/en/ljspeech/tacotron2-DDC" - ), - inquirer.List('vocoder_choose', - message="Choose a vocoder model to load", - choices=model_list['vocoder_models'], - ), - inquirer.List('use_cuda', - message="Run model on CUDA?", - choices=[True,False], - default=True, - ), + inquirer.List( + "tts_choose", + message="Choose a tts model to load", + choices=model_list["tts_models"], + default="tts_models/en/ljspeech/tacotron2-DDC", + ), + inquirer.List( + "vocoder_choose", + message="Choose a vocoder model to load", + choices=model_list["vocoder_models"], + ), + inquirer.List( + "use_cuda", + message="Run model on CUDA?", + choices=[True, False], + default=True, + ), ] answers_model_load = inquirer.prompt(model_load_questions, theme=GreenPassion()) return answers_model_load + def official_zoo_info_inquirer(): - joint_model_list=manager.list_tts_models(print_list=False)+manager.list_vocoder_models(print_list=False) + joint_model_list = manager.list_tts_models(print_list=False) + manager.list_vocoder_models(print_list=False) model_info_questions = [ - inquirer.List('model_choose_for_info', - message="Choose a tts model for info", - choices=joint_model_list, - ), + inquirer.List( + "model_choose_for_info", + message="Choose a tts model for info", + choices=joint_model_list, + ), ] answers_model_info_request = inquirer.prompt(model_info_questions, theme=GreenPassion()) return answers_model_info_request + def custom_model_inquirer(): custom_model_load_questions = [ - inquirer.Text('model_path', - message="Path to TTS model path", - default=None, - ), - inquirer.Text('model_config_path', - message="Path to TTS model config path", - default=None, - ), - inquirer.Text('vocoder_path', - message="Path to vocoder model file.", - default=None, - ), - inquirer.Text('vocoder_config_path', - message="Path to vocoder model config file.", - default=None, - ), - inquirer.Text('encoder_path', - message="Path to speaker encoder model file.", - default=None, - ), - inquirer.Text('encoder_config_path', - message="Path to speaker encoder config file.", - default=None, - ), - inquirer.List('use_cuda', - message="Run model on CUDA?", - choices=[True,False], - default=True, - ), + inquirer.Text( + "model_path", + message="Path to TTS model path", + default=None, + ), + inquirer.Text( + "model_config_path", + message="Path to TTS model config path", + default=None, + ), + inquirer.Text( + "vocoder_path", + message="Path to vocoder model file.", + default=None, + ), + inquirer.Text( + "vocoder_config_path", + message="Path to vocoder model config file.", + default=None, + ), + inquirer.Text( + "encoder_path", + message="Path to speaker encoder model file.", + default=None, + ), + inquirer.Text( + "encoder_config_path", + message="Path to speaker encoder config file.", + default=None, + ), + inquirer.List( + "use_cuda", + message="Run model on CUDA?", + choices=[True, False], + default=True, + ), ] answers_custom_model_load = inquirer.prompt(custom_model_load_questions, theme=GreenPassion()) return answers_custom_model_load + def multispeaker_inquirer(): multispeaker_questions = [ - inquirer.Text('speakers_file_path', - message="JSON file for multi-speaker model.", - default=None, - ), - inquirer.Text('language_ids_file_path', - message="JSON file for multi-lingual model.", - default=None, - ), - inquirer.Text('speaker_idx', - message="Enter speaker idx", - default=None - ), - inquirer.Text('language_idx', - message="Enter language idx", - default=None - ), - inquirer.Text('speaker_wav', - message="Enter speaker wav file path", - default=None - ), - inquirer.Text('reference_wav', - message="Enter ref wav file path", - default=None - ), - inquirer.Text('reference_speaker_idx', - message="Enter reference speaker idx", - default=None - ), + inquirer.Text( + "speakers_file_path", + message="JSON file for multi-speaker model.", + default=None, + ), + inquirer.Text( + "language_ids_file_path", + message="JSON file for multi-lingual model.", + default=None, + ), + inquirer.Text("speaker_idx", message="Enter speaker idx", default=None), + inquirer.Text("language_idx", message="Enter language idx", default=None), + inquirer.Text("speaker_wav", message="Enter speaker wav file path", default=None), + inquirer.Text("reference_wav", message="Enter ref wav file path", default=None), + inquirer.Text("reference_speaker_idx", message="Enter reference speaker idx", default=None), ] answers_multispeaker = inquirer.prompt(multispeaker_questions, theme=GreenPassion()) return answers_multispeaker + def capacitron_inquirer(): capacitron_questions = [ - inquirer.Text('capacitron_style_wav', - message="Enter capacitron style wav path", - default=None - ), - inquirer.Text('capacitron_style_text', - message="Enter capacitron style text", - default=None - ), + inquirer.Text("capacitron_style_wav", message="Enter capacitron style wav path", default=None), + inquirer.Text("capacitron_style_text", message="Enter capacitron style text", default=None), ] answers_capacitron = inquirer.prompt(capacitron_questions, theme=GreenPassion()) return answers_capacitron + def continue_inquirer(): continue_questions = [ - inquirer.List('to_do', - message="What to do next?", - choices=[ - 'try another text-input', - 'restart tts', - 'exit tts' - ] - ), - ] + inquirer.List( + "to_do", message="What to do next?", choices=["try another text-input", "restart tts", "exit tts"] + ), + ] continue_answers = inquirer.prompt(continue_questions, theme=GreenPassion()) return continue_answers + def tts_inquirer( synthesizer, speaker_idx, @@ -162,20 +152,18 @@ def tts_inquirer( reference_wav, reference_speaker_idx, capacitron_style_wav, - capacitron_style_text + capacitron_style_text, ): tts_questions = [ - inquirer.Text('text_input', - message="Type text to convert to speech", - ), - inquirer.Text('out_path', - message="Enter output wav path", - default="tts_output.wav" - ), + inquirer.Text( + "text_input", + message="Type text to convert to speech", + ), + inquirer.Text("out_path", message="Enter output wav path", default="tts_output.wav"), ] answers_tts = inquirer.prompt(tts_questions, theme=GreenPassion()) - text = str2none(answers_tts['text_input']) - outpath = answers_tts['out_path'] + text = str2none(answers_tts["text_input"]) + outpath = answers_tts["out_path"] text = text if text is not None else "Enter random text." print(f" > Text: {text}") # kick it @@ -194,150 +182,159 @@ def tts_inquirer( print(f" > Saving output to {outpath}") synthesizer.save_wav(wav, outpath) - continue_answers=continue_inquirer() + continue_answers = continue_inquirer() return continue_answers + def block_prompt(synthesizer, isCapacitron=False): - speaker_idx=None - language_idx=None - speaker_wav=None - reference_wav=reference_wav=None - reference_speaker_idx=None - capacitron_style_wav=None - capacitron_style_text=None - isCapacitron=isCapacitron + speaker_idx = None + language_idx = None + speaker_wav = None + reference_wav = reference_wav = None + reference_speaker_idx = None + capacitron_style_wav = None + capacitron_style_text = None if synthesizer.tts_speakers_file or hasattr(synthesizer.tts_model.speaker_manager, "ids"): - answers_multispeaker=multispeaker_inquirer() - for key,item in answers_multispeaker.items(): - answers_multispeaker[key]=str2none(item) - speaker_idx=answers_multispeaker['speaker_idx'] - language_idx=answers_multispeaker['language_idx'] - speaker_wav=answers_multispeaker['speaker_wav'] - reference_wav=reference_wav=answers_multispeaker['reference_wav'] - reference_speaker_idx=answers_multispeaker['reference_speaker_idx'] - + answers_multispeaker = multispeaker_inquirer() + for key, item in answers_multispeaker.items(): + answers_multispeaker[key] = str2none(item) + speaker_idx = answers_multispeaker["speaker_idx"] + language_idx = answers_multispeaker["language_idx"] + speaker_wav = answers_multispeaker["speaker_wav"] + reference_wav = reference_wav = answers_multispeaker["reference_wav"] + reference_speaker_idx = answers_multispeaker["reference_speaker_idx"] + if isCapacitron: answers_capacitron = capacitron_inquirer() - for key,item in answers_capacitron.items(): - answers_capacitron[key]=str2none(item) - capacitron_style_wav=answers_capacitron['capacitron_style_wav'] - capacitron_style_text=answers_capacitron['capacitron_style_text'] + for key, item in answers_capacitron.items(): + answers_capacitron[key] = str2none(item) + capacitron_style_wav = answers_capacitron["capacitron_style_wav"] + capacitron_style_text = answers_capacitron["capacitron_style_text"] continue_answers = tts_inquirer( - synthesizer, - speaker_idx, - language_idx, - speaker_wav, - reference_wav, - reference_speaker_idx, - capacitron_style_wav, - capacitron_style_text - ) + synthesizer, + speaker_idx, + language_idx, + speaker_wav, + reference_wav, + reference_speaker_idx, + capacitron_style_wav, + capacitron_style_text, + ) - if continue_answers['to_do'] == 'exit tts': + if continue_answers["to_do"] == "exit tts": return - if continue_answers['to_do'] == 'restart tts': + if continue_answers["to_do"] == "restart tts": print("restart") init_prompt() - if continue_answers['to_do'] == 'try another text-input': + if continue_answers["to_do"] == "try another text-input": block_prompt(synthesizer, isCapacitron=isCapacitron) + def init_prompt(): - model_path=None - config_path=None - speakers_file_path=None - language_ids_file_path=None - vocoder_path=None - vocoder_config_path=None - encoder_path=None - encoder_config_path=None - use_cuda=True - isCapacitron=False + model_path = None + config_path = None + speakers_file_path = None + language_ids_file_path = None + vocoder_path = None + vocoder_config_path = None + encoder_path = None + encoder_config_path = None + use_cuda = True + isCapacitron = False init_questions = [ - inquirer.List('to_do', - message="What do you need?", - choices=[ - 'get info from official model zoo', - 'play with official model zoo', - 'play with your own model', - 'exit tts' - ] - ), + inquirer.List( + "to_do", + message="What do you need?", + choices=[ + "get info from official model zoo", + "play with official model zoo", + "play with your own model", + "exit tts", + ], + ), ] init_answers = inquirer.prompt(init_questions, theme=GreenPassion()) - if init_answers['to_do'] == 'get info from official model zoo': + if init_answers["to_do"] == "get info from official model zoo": answers_model_load = official_zoo_info_inquirer() - manager.model_info_by_full_name(answers_model_load['model_choose_for_info']) + manager.model_info_by_full_name(answers_model_load["model_choose_for_info"]) - if init_answers['to_do'] == 'exit tts': + if init_answers["to_do"] == "exit tts": return - if init_answers['to_do'] == 'play with official model zoo': + if init_answers["to_do"] == "play with official model zoo": answers_model_load = official_zoo_inquirer() - tts_model_name=answers_model_load['tts_choose'] + tts_model_name = answers_model_load["tts_choose"] model_path, config_path, model_item = manager.download_model(tts_model_name) - vocoder_name=answers_model_load['vocoder_choose'] if answers_model_load['vocoder_choose'] != "default_vocoder" else model_item["default_vocoder"] + vocoder_name = ( + answers_model_load["vocoder_choose"] + if answers_model_load["vocoder_choose"] != "default_vocoder" + else model_item["default_vocoder"] + ) if vocoder_name is not None: vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name) - use_cuda=answers_model_load['use_cuda'] + use_cuda = answers_model_load["use_cuda"] synthesizer = Synthesizer( - model_path, - config_path, - speakers_file_path, - language_ids_file_path, - vocoder_path, - vocoder_config_path, - encoder_path, - encoder_config_path, - use_cuda, + model_path, + config_path, + speakers_file_path, + language_ids_file_path, + vocoder_path, + vocoder_config_path, + encoder_path, + encoder_config_path, + use_cuda, ) - if 'capacitron' in tts_model_name: + if "capacitron" in tts_model_name: isCapacitron = True block_prompt(synthesizer, isCapacitron=isCapacitron) - if init_answers['to_do'] == 'play with your own model': + if init_answers["to_do"] == "play with your own model": answers_custom_model_load = custom_model_inquirer() - for key,item in answers_custom_model_load.items(): - answers_custom_model_load[key]=str2none(item) - - model_path=answers_custom_model_load['model_path'] - config_path=answers_custom_model_load['model_config_path'] - vocoder_path=answers_custom_model_load['vocoder_path'] - vocoder_config_path=answers_custom_model_load['vocoder_config_path'] - encoder_path=answers_custom_model_load['encoder_path'] - encoder_config_path=answers_custom_model_load['encoder_config_path'] - use_cuda=answers_custom_model_load['use_cuda'] - + for key, item in answers_custom_model_load.items(): + answers_custom_model_load[key] = str2none(item) + + model_path = answers_custom_model_load["model_path"] + config_path = answers_custom_model_load["model_config_path"] + vocoder_path = answers_custom_model_load["vocoder_path"] + vocoder_config_path = answers_custom_model_load["vocoder_config_path"] + encoder_path = answers_custom_model_load["encoder_path"] + encoder_config_path = answers_custom_model_load["encoder_config_path"] + use_cuda = answers_custom_model_load["use_cuda"] + synthesizer = Synthesizer( - model_path, - config_path, - speakers_file_path, - language_ids_file_path, - vocoder_path, - vocoder_config_path, - encoder_path, - encoder_config_path, - use_cuda, + model_path, + config_path, + speakers_file_path, + language_ids_file_path, + vocoder_path, + vocoder_config_path, + encoder_path, + encoder_config_path, + use_cuda, ) - if 'use_capacitron_vae' in synthesizer.tts_config: #find if model is capacitron + if "use_capacitron_vae" in synthesizer.tts_config: # find if model is capacitron print("yes cap") isCapacitron = True block_prompt(synthesizer, isCapacitron=isCapacitron) + def main(): from TTS.bin.frogie import ascii_art_printer + ascii_art_printer() print("welcome to COQUI TTS") init_prompt() - + + if __name__ == "__main__": - main() \ No newline at end of file + main()