Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
"""Internationalization strings for VoxCPM Training WebUI.

All translatable UI strings are defined here. Widget creation in
lora_ft_webui.py uses t("key") for initial display; change_language()
uses STRINGS[lang]["key"] to switch all elements.

To add a new language: add a new key to STRINGS with all the same keys.
"""

import os

DEFAULT_LANG = os.environ.get("VOXCPM_LANG", "zh")

STRINGS = {
"zh": {
"title": "VoxCPM LoRA WebUI",
"tab_train": "训练 (Training)",
"tab_infer": "推理 (Inference)",
"pretrained_path": "预训练模型路径",
"train_manifest": "训练数据清单 (jsonl)",
"val_manifest": "验证数据清单 (可选)",
"lr": "学习率 (Learning Rate)",
"max_iters": "最大迭代次数",
"batch_size": "批次大小 (Batch Size)",
"lora_rank": "LoRA Rank",
"lora_alpha": "LoRA Alpha",
"save_interval": "保存间隔 (Steps)",
"start_train": "开始训练",
"stop_train": "停止训练",
"train_logs": "训练日志",
"text_to_synth": "合成文本",
"voice_cloning": "### 声音克隆 (可选)",
"ref_audio": "参考音频",
"ref_text": "参考文本 (可选)",
"select_lora": "选择 LoRA 模型",
"cfg_scale": "CFG Scale (引导系数)",
"infer_steps": "推理步数",
"seed": "随机种子 (Seed)",
"gen_audio": "生成音频",
"gen_output": "生成结果",
"status": "状态",
"lang_select": "Language / 语言",
"refresh": "刷新",
"output_name": "输出目录名称 (可选,若存在则继续训练)",
"grad_accum_steps": "梯度累积 (grad_accum_steps)",
"num_workers": "数据加载线程 (num_workers)",
"log_interval": "日志间隔 (log_interval)",
"valid_interval": "验证间隔 (valid_interval)",
"weight_decay": "权重衰减 (weight_decay)",
"warmup_steps": "预热步数 (warmup_steps)",
"max_steps": "最大步数 (max_steps)",
"sample_rate": "采样率 (sample_rate)",
"max_grad_norm": "梯度裁剪 (max_grad_norm, 0=关闭)",
"enable_lm": "启用 LoRA LM (enable_lm)",
"enable_dit": "启用 LoRA DIT (enable_dit)",
"enable_proj": "启用投影 (enable_proj)",
"dropout": "LoRA 丢弃率 (Dropout)",
"tensorboard_path": "Tensorboard 路径 (可选)",
"hf_model_id": "HuggingFace Model ID (e.g., openbmb/VoxCPM2)",
"distribute": "分发模式 (distribute)",
"header_title": "### 强大的语音合成和 LoRA 微调工具",
"header_subtitle": "支持语音克隆、LoRA 模型训练和推理的完整解决方案",
"train_setup_title": "### 🎯 模型训练设置",
"train_setup_desc": "配置你的 LoRA 微调训练参数",
"base_config_header": "#### 📁 基础配置",
"train_params_header": "#### ⚙️ 训练参数",
"advanced_accordion": "🔧 高级选项 (Advanced)",
"distribution_header": "#### 分发选项 (Distribution)",
"train_logs_header": "#### 📊 训练日志",
"infer_title": "### 🎤 语音合成",
"infer_desc": "使用训练好的 LoRA 模型生成语音,支持 LoRA 微调和声音克隆",
"input_config_header": "#### 📝 输入配置",
"voice_clone_header": "**🎭 声音克隆(可选)**",
"model_select_header": "#### 🤖 模型选择",
"gen_params_header": "#### ⚙️ 生成参数",
"gen_output_header": "#### 🎧 生成结果",
"status_header": "#### 📋 状态信息",
"placeholder_synth": "输入要合成的文本内容...",
"placeholder_ref_text": "如不填写,将自动识别参考音频内容",
"placeholder_status": "等待生成...",
"info_cfg": "引导系数,值越大越贴近提示",
"info_steps": "生成质量与步数成正比,但耗时更长",
"info_seed": "-1 为随机,固定值可复现结果",
"info_lora_select": "选择训练好的 LoRA 模型,或选择 None 使用基础模型",
"log_ref_audio_no_text": "参考音频已提供但缺少文本,自动识别中...",
"log_auto_recognized": "自动识别文本: {text}",
"error_asr_failed": "错误:无法识别参考音频内容,请手动填写参考文本",
"error_asr_exception": "错误:自动识别参考音频失败 - {error}",
"log_refresh_lora": "刷新 LoRA 列表: 找到 {count} 个检查点",
},
"en": {
"title": "VoxCPM LoRA WebUI",
"tab_train": "Training",
"tab_infer": "Inference",
"pretrained_path": "Pretrained Model Path",
"train_manifest": "Train Manifest (jsonl)",
"val_manifest": "Validation Manifest (Optional)",
"lr": "Learning Rate",
"max_iters": "Max Iterations",
"batch_size": "Batch Size",
"lora_rank": "LoRA Rank",
"lora_alpha": "LoRA Alpha",
"save_interval": "Save Interval",
"start_train": "▶️ Start Training",
"stop_train": "⏹️ Stop Training",
"train_logs": "Training Logs",
"text_to_synth": "Text to Synthesize",
"voice_cloning": "### Voice Cloning (Optional)",
"ref_audio": "Reference Audio",
"ref_text": "Reference Text (Optional)",
"select_lora": "Select LoRA Checkpoint",
"cfg_scale": "CFG Scale",
"infer_steps": "Inference Steps",
"seed": "Seed",
"gen_audio": "🎵 Generate Audio",
"gen_output": "Generated Audio",
"status": "Status",
"lang_select": "Language / 语言",
"refresh": "🔄 Refresh Models",
"output_name": "Output Name (Optional, resume if exists)",
"header_title": "### Powerful voice synthesis and LoRA fine-tuning",
"header_subtitle": "Complete solution for voice cloning, LoRA model training and inference",
"train_setup_title": "### 🎯 Model Training Setup",
"train_setup_desc": "Configure your LoRA fine-tuning parameters",
"base_config_header": "#### 📁 Base Configuration",
"train_params_header": "#### ⚙️ Training Parameters",
"advanced_accordion": "🔧 Advanced Options",
"distribution_header": "#### Distribution Options",
"train_logs_header": "#### 📊 Training Logs",
"infer_title": "### 🎤 Voice Synthesis",
"infer_desc": "Generate speech with trained LoRA models — supports fine-tuning and voice cloning",
"input_config_header": "#### 📝 Input Configuration",
"voice_clone_header": "**🎭 Voice Cloning (Optional)**",
"model_select_header": "#### 🤖 Model Selection",
"gen_params_header": "#### ⚙️ Generation Parameters",
"gen_output_header": "#### 🎧 Generated Output",
"status_header": "#### 📋 Status",
"placeholder_synth": "Enter text to synthesize...",
"placeholder_ref_text": "If empty, auto-recognizes from reference audio",
"placeholder_status": "Waiting for generation...",
"info_cfg": "Guidance scale — higher values follow the prompt more closely",
"info_steps": "Higher = better quality but slower",
"info_seed": "-1 for random, fixed value for reproducible results",
"info_lora_select": "Select a trained LoRA model, or None for base model",
"grad_accum_steps": "Grad Accum Steps",
"num_workers": "Num Workers",
"log_interval": "Log Interval",
"valid_interval": "Valid Interval",
"weight_decay": "Weight Decay",
"warmup_steps": "Warmup Steps",
"max_steps": "Max Steps",
"sample_rate": "Sample Rate",
"max_grad_norm": "Max Grad Norm (0=disabled)",
"enable_lm": "Enable LoRA LM",
"enable_dit": "Enable LoRA DIT",
"enable_proj": "Enable Projection",
"dropout": "LoRA Dropout",
"tensorboard_path": "Tensorboard Path (Optional)",
"hf_model_id": "HuggingFace Model ID (e.g., openbmb/VoxCPM2)",
"distribute": "Distribute Mode",
"log_ref_audio_no_text": "Reference audio provided without text, auto-recognizing...",
"log_auto_recognized": "Auto-recognized text: {text}",
"error_asr_failed": "Error: Could not recognize reference audio, please enter reference text manually",
"error_asr_exception": "Error: Reference audio recognition failed - {error}",
"log_refresh_lora": "Refresh LoRA list: found {count} checkpoints",
},
}


def t(key: str, lang: str = None) -> str:
"""Get translated string. Uses DEFAULT_LANG if lang not specified."""
if lang is None:
lang = DEFAULT_LANG
return STRINGS.get(lang, STRINGS["en"]).get(key, STRINGS["en"].get(key, key))
Loading