import tempfile from typing import Optional from TTS.config import load_config import gradio as gr import numpy as np from TTS.utils.manage import ModelManager from TTS.utils.synthesizer import Synthesizer import os MODEL_NAMES = ["Celtia"]#, "Icia", "Sabela"] # reorder models print(MODEL_NAMES) def tts(text: str, choosen_model: str = "sabela.pth" ): # if text is "celtia" take celtia.pth and celtia_config.json if choosen_model == "Celtia": config_path = "celtia_config.json" model_file = "celtia.pth" elif choosen_model == "Icia": config_path = "icia_config.json" model_file = "icia.pth" else: config_path = "sabela_config.json" model_file = "sabela.pth" model_path = os.path.join(os.getcwd(), model_file) vocoder_path = None vocoder_config_path = None print(f"Using model: {model_path}\n" f"Using config: {config_path}\n" f"Using vocoder: {vocoder_path}\n" f"Using vocoder config: {vocoder_config_path}" ) synthesizer = Synthesizer( model_path, config_path, None, vocoder_path, vocoder_config_path, ) # synthesize if synthesizer is None: raise NameError("model not found") wavs = synthesizer.tts(text) # return output with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp: synthesizer.save_wav(wavs, fp) return fp.name title = """