From 1b4ed5aa49b5343d0cc40bc304013a4e7f357ae7 Mon Sep 17 00:00:00 2001 From: gluttony-10 <326581344@qq.com> Date: Sat, 13 Dec 2025 16:49:29 +0800 Subject: [PATCH] Installation and Runtime Optimizations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Dependency Optimizations 1.1. Pinned gradio to version 5.49.0. Versions gradio>=6 cause unexplained, long hangs on Windows without any error logs. 1.2. Created a new minimal dependencies file, requirements-mini.txt, with looser version constraints for broader compatibility. 1.3. Updated torch to 2.7.1+cu128 to support NVIDIA 50-series GPUs, which are not supported by older versions. 1.4. Added the wetext dependency with system-specific installation logic. On Windows, the easier-to-install wetext package is used, while on Linux, WeTextProcessing is installed. 2. Runtime Optimizations 2.1. Optimized cosyvoice/frontend.py by adding the wetext import. 2.2. Added launch parameters to the Gradio demo file. 2.3. Fixed the Gradio demo file for compatibility with the updated Gradio version. 2.4. Lowered the onnxruntime logging level to reduce verbosity from a specific dependency version. 3. README Optimizations 3.1. Optimized the “Dependency Installation” section. 3.2. Suggestion: The README could benefit from a major restructuring. The introduction and project highlights should be at the top. The quick start guide (minimal installation and run) should be in the middle. Optional installations and other information can be placed at the end. 3.3. Recommendation: Add a models directory to the project structure. This is crucial. --- README.md | 4 ++-- README_zh.md | 4 ++-- cosyvoice/cli/frontend.py | 13 +++++++++---- requirements-mini.txt | 21 +++++++++++++++++++++ requirements.txt | 2 +- tools/gradio_app.py | 21 ++++++++++++++++----- 6 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 requirements-mini.txt diff --git a/README.md b/README.md index ee5f98d..f8a2c63 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ Ensure you use Python 3.10 - Python 3.12 versions. git clone https://github.com/zai-org/GLM-TTS.git cd GLM-TTS -# Install dependencies -pip install -r requirements.txt +# Install minimum runtime dependencies +pip install -r requirements-mini.txt # Install reinforcement learning related dependencies (optional) cd grpo/modules diff --git a/README_zh.md b/README_zh.md index ed1453b..a8a11a1 100644 --- a/README_zh.md +++ b/README_zh.md @@ -44,8 +44,8 @@ GLM-TTS 是一个基于大型语言模型的高质量文本到语音(TTS)合成 git clone https://github.com/zai-org/GLM-TTS.git cd GLM-TTS -# 安装依赖 -pip install -r requirements.txt +# 安装最小运行依赖 +pip install -r requirements-mini.txt # 安装强化学习相关依赖(可选) cd grpo/modules diff --git a/cosyvoice/cli/frontend.py b/cosyvoice/cli/frontend.py index 3d752ef..7f51eb6 100644 --- a/cosyvoice/cli/frontend.py +++ b/cosyvoice/cli/frontend.py @@ -41,10 +41,15 @@ import ttsfrd use_ttsfrd = True except ImportError: - print("Warning: failed to import ttsfrd, use WeTextProcessing instead") - from tn.chinese.normalizer import Normalizer as ZhNormalizer - from tn.english.normalizer import Normalizer as EnNormalizer use_ttsfrd = False + try: + print("Warning: failed to import ttsfrd, use WeTextProcessing instead") + from tn.chinese.normalizer import Normalizer as ZhNormalizer + from tn.english.normalizer import Normalizer as EnNormalizer + except ImportError: + print("Warning: failed to import ttsfrd and WeTextProcessing, use wetext instead") + from wetext import Normalizer as ZhNormalizer + from wetext import Normalizer as EnNormalizer class SpeechTokenizer: @@ -144,7 +149,7 @@ def __init__(self, use_phoneme: bool = False): remove_erhua=False, full_to_half=True, remove_interjections=False, - overwrite_cache=True + #overwrite_cache=True ) self.en_tn_model = EnNormalizer() diff --git a/requirements-mini.txt b/requirements-mini.txt new file mode 100644 index 0000000..4662c31 --- /dev/null +++ b/requirements-mini.txt @@ -0,0 +1,21 @@ +torch==2.7.1 +torchaudio +torchvision +transformers +huggingface_hub +modelscope +gradio==5.49.0 +numpy==1.26.4 +contractions +inflect +funasr +onnxruntime-gpu==1.22.0 +pypinyin +emoji +pronouncing +hyperpyyaml +peft +tiktoken +x_transformers +wetext; sys_platform == 'win32' +WeTextProcessing; sys_platform != 'win32' \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index a0c9293..4f7ad73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,7 +26,7 @@ emoji==2.14.1 evaluation==0.0.2 fastapi==0.123.9 funasr==1.1.6 -gradio==6.1.0 +gradio==5.49.0 HyperPyYAML==1.2.2 jieba==0.42.1 jiwer==4.0.0 diff --git a/tools/gradio_app.py b/tools/gradio_app.py index 9164f87..75a65bb 100644 --- a/tools/gradio_app.py +++ b/tools/gradio_app.py @@ -11,6 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import onnxruntime +onnxruntime.set_default_logger_severity(3) import gradio as gr import torch import numpy as np @@ -21,6 +23,14 @@ generate_long, DEVICE ) +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("--server_name", type=str, default="0.0.0.0", help="IP address, change to 0.0.0.0 for LAN access") +parser.add_argument("--server_port", type=int, default=8048, help="Port number to use") +parser.add_argument("--share", action="store_true", help="Whether to enable gradio sharing") +parser.add_argument("--mcp_server", action="store_true", help="Whether to enable mcp server") +args = parser.parse_args() # Configure logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') @@ -157,7 +167,7 @@ def clear_memory(): # --- Gradio UI Layout --- -with gr.Blocks(title="GLMTTS Inference") as app: +with gr.Blocks(title="GLMTTS Inference", theme=gr.themes.Soft()) as app: gr.Markdown("# 🎵 GLMTTS Open Source Demo") gr.Markdown("Zero-shot text-to-speech generation using GLMTTS models.") @@ -220,8 +230,9 @@ def clear_memory(): if __name__ == "__main__": app.queue().launch( - server_name="0.0.0.0", - server_port=8048, - theme=gr.themes.Soft(), - share=False + server_name=args.server_name, + server_port=args.server_port, + share=args.share, + mcp_server=args.mcp_server, + inbrowser=True, ) \ No newline at end of file