Spaces:
Running on Zero
Running on Zero
Update inference_gradio.py
Browse files34 unmodified lines35363738394041424344454644 unmodified lines919293949596979882 unmodified lines18118218318418518618750 unmodified lines238239240241242243244245246247248249250231 unmodified lines482483484485486487488489490491492493494104 unmodified lines59960060160260360460534 unmodified linesREPO_ROOT = Path(__file__).resolve().parent# Local pretrained root (used when running from a repo / Space that bundles weights)PRETRAINED_ROOT = str(REPO_ROOT / "pretrained_models")CKPTS_ROOT = os.path.join(PRETRAINED_ROOT, "ckpts")# HF location for pretrained assets (used as a fallback when local files are missing)# HF_PRETRAINED_ROOT = "hf://LEMAS-Project/LEMAS-TTS/blob/main/pretrained_models"# 1) 指向你仓库里的 libespeak-ng.soESPEAK_LIB = os.path.join(PRETRAINED_ROOT, "espeak-ng-lib", "libespeak-ng.so")44 unmodified linesreturn output_audio.squeeze().T.numpy(), 44100denoise_model = UVR5(model_dir=os.path.join(PRETRAINED_ROOT, "uvr5"),code_dir=str(REPO_ROOT / "uvr5"),)def load_wav(audio_info, sr=16000, channel=1):82 unmodified linesdef get_available_projects():"""Get available project names from data directory"""data_paths = [str(PRETRAINED_ROOT / "data"),]project_list = []50 unmodified linesuse_prosody_encoder = True if "prosody" in str(ckpt_resolved) else False# Resolve vocab file (local or HF)local_vocab = Path(PRETRAINED_ROOT) / "data" / project / "vocab.txt"if local_vocab.is_file():vocab_file = str(local_vocab)else:remote_vocab_map = {"multilingual_grl": f"{PRETRAINED_ROOT}/data/multilingual_grl/vocab.txt","multilingual_prosody": f"{PRETRAINED_ROOT}/data/multilingual_prosody/vocab.txt",}remote_vocab = remote_vocab_map.get(project)if remote_vocab is None:231 unmodified lines# Examplesdef _resolve_example(name: str) -> str:local = os.path.join(PRETRAINED_ROOT, "data", "test_examples", name)if os.path.isfile(local):return localremote_map = {"en.wav": os.path.join(PRETRAINED_ROOT, "data", "test_examples", "en.wav"),"es.wav": os.path.join(PRETRAINED_ROOT, "data", "test_examples", "es.wav"),"pt.wav": os.path.join(PRETRAINED_ROOT, "data", "test_examples", "pt.wav"),}url = remote_map.get(name)return str(cached_path(url)) if url is not None else ""104 unmodified linesserver_port=port,share=share,show_api=api,allowed_paths=[str(os.path.join(PRETRAINED_ROOT, "data"))],)34 unmodified lines353637383940414243444544 unmodified lines909192939495969782 unmodified lines18018118218318418518650 unmodified lines237238239240241242243244245246247248249231 unmodified lines481482483484485486487488489490491492493104 unmodified lines59859960060160260360434 unmodified linesREPO_ROOT = Path(__file__).resolve().parent# Local pretrained root (used when running from a repo / Space that bundles weights)# PRETRAINED_ROOT = str(REPO_ROOT / "pretrained_models")# HF location for pretrained assets (used as a fallback when local files are missing)PRETRAINED_ROOT = "hf://LEMAS-Project/LEMAS-TTS/pretrained_models"CKPTS_ROOT = os.path.join(PRETRAINED_ROOT, "ckpts")# 1) 指向你仓库里的 libespeak-ng.soESPEAK_LIB = os.path.join(PRETRAINED_ROOT, "espeak-ng-lib", "libespeak-ng.so")44 unmodified linesreturn output_audio.squeeze().T.numpy(), 44100denoise_model = UVR5(model_dir=cached_path(os.path.join(PRETRAINED_ROOT, "uvr5")),code_dir=cached_path(str(REPO_ROOT / "uvr5")),)def load_wav(audio_info, sr=16000, channel=1):82 unmodified linesdef get_available_projects():"""Get available project names from data directory"""data_paths = [cached_path(str(PRETRAINED_ROOT / "data")),]project_list = []50 unmodified linesuse_prosody_encoder = True if "prosody" in str(ckpt_resolved) else False# Resolve vocab file (local or HF)local_vocab = cached_path(str(PRETRAINED_ROOT / "data" / project / "vocab.txt"))if local_vocab.is_file():vocab_file = str(local_vocab)else:remote_vocab_map = {"multilingual_grl": cached_path(f"{PRETRAINED_ROOT}/data/multilingual_grl/vocab.txt"),"multilingual_prosody": cached_path(f"{PRETRAINED_ROOT}/data/multilingual_prosody/vocab.txt"),}remote_vocab = remote_vocab_map.get(project)if remote_vocab is None:231 unmodified lines# Examplesdef _resolve_example(name: str) -> str:local = cached_path(os.path.join(PRETRAINED_ROOT, "data", "test_examples", name))if os.path.isfile(local):return localremote_map = {"en.wav": cached_path(os.path.join(PRETRAINED_ROOT, "data", "test_examples", "en.wav")),"es.wav": cached_path(os.path.join(PRETRAINED_ROOT, "data", "test_examples", "es.wav")),"pt.wav": cached_path(os.path.join(PRETRAINED_ROOT, "data", "test_examples", "pt.wav")),}url = remote_map.get(name)return str(cached_path(url)) if url is not None else ""104 unmodified linesserver_port=port,share=share,show_api=api,allowed_paths=[str(cached_path(os.path.join(PRETRAINED_ROOT, "data")))],)
inference_gradio.py+14-15