# -*- coding: utf-8 -*- """ @author:XuMing(xuming624@qq.com) @description: Re-train by TWMAN """ import hashlib import os import ssl import gradio as gr import torch from loguru import logger ssl._create_default_https_context = ssl._create_unverified_context import nltk nltk.download('cmudict') from parrots import TextToSpeech device = "cuda" if torch.cuda.is_available() else "cpu" logger.info(f"device: {device}") half = True if device == "cuda" else False m = TextToSpeech(speaker_model_path="DeepLearning101/GPT-SoVITS_TWMAN", speaker_name="TWMAN", device=device, half=half) m.predict(text="台灣南波萬。Taiwan Number One.", text_language="auto", output_path="output_audio.wav") assert os.path.exists("output_audio.wav"), "output_audio.wav not found" def get_text_hash(text: str): return hashlib.md5(text.encode('utf-8')).hexdigest() def do_tts_wav_predict(text: str, output_path: str = None): if output_path is None: output_path = f"output_audio_{get_text_hash(text)}.wav" if not os.path.exists(output_path): m.predict(text, text_language="auto", output_path=output_path) return output_path with gr.Blocks(title="TTS WebUI") as app: gr.Markdown(value=""" #