Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
88a4ba4
feat: Enhance dialogue synthesis functionality and speaker management
selfuppen Nov 5, 2025
c79d1bd
feat: Add speaker management controls and improve UI localization
selfuppen Nov 5, 2025
1f73bc3
feat: Enhance dialogue synthesis with pause handling and speaker diff…
selfuppen Nov 5, 2025
45c8143
feat:[WebUI] Add functionality for saving and downloading separated s…
selfuppen Nov 10, 2025
dd9758a
feat: 每次生成对话音频时,所有输出文件都会保存到 outputs/separated_speakers/{timestamp}/ 目…
Dec 12, 2025
ac60bd0
feat: 通过数字选择器设置需要多少个输入框
Dec 12, 2025
3ace9a7
feat: 同一次提交的所有任务都会保存在同一个时间戳文件夹下,每个任务的文件都在各自的编号子文件夹中,便于管理和查找。
Dec 12, 2025
973d0cb
feat: 已完成的功能
Dec 13, 2025
a9e5a33
feat:实现这些功能:
Dec 13, 2025
cb85fbe
feat: 增加当前配置导出/导入功能,并支持你要求的两种加载方式:
Dec 13, 2025
edaf73d
fix: 修复问题:
Dec 13, 2025
75b7560
feat: 新增按行分割文件的功能:
Dec 13, 2025
2760858
feat: 已去掉每个文本输入框子任务的压缩功能,仅保留 all.zip 的整体压缩
Dec 13, 2025
be65f54
refactor: 重构webui.py:
Dec 13, 2025
43a94be
refactor:
Dec 14, 2025
90b5c16
refactor: UI 重新布局
Dec 14, 2025
c2f90e9
fix:修复配置导出出错
Dec 14, 2025
dd13b7c
fix: 修复功能:
Dec 14, 2025
850703e
refactor: webui 布局和功能的优化,具体修改如下:
Dec 14, 2025
0894715
refactor: UI 优化
Dec 14, 2025
18fab2f
feat: 说话人设置标题问题: 收起时,需要展示所有对话人的标签信息,以便快速看到有哪些对话人.
Dec 14, 2025
bc57576
feat: ui 优化
Dec 14, 2025
0952d3d
feat: 功能调整:"合成文本输入框"支持显示行号
Dec 14, 2025
06e0d72
feat: 添加 S7.json 配置文件,包含 7 个说话人及其音频和文本信息,同时优化合成文本输入框以支持行号显示
Dec 14, 2025
82dd3d5
fix: 修复内容
Dec 14, 2025
8e4f59c
feat: 修改总结
Dec 14, 2025
d366db6
feat: 增加vllm 支持
Dec 14, 2025
0ea2d4b
feat: 处理时间会显示在界面和日志文件中
Dec 14, 2025
5a6de78
fix: 清理回调函数中的冗余代码,优化配置管理器中的说话人标签更新逻辑。移除多余的返回语句,并在备注字段更新后确保标签正确显示。
Dec 14, 2025
7f2a596
fix: 导入配置后,说话人标签会立即显示正确的备注名称(如"S1:佩奇"、"S2:米小圈"),无需手动修改备注名。
Dec 15, 2025
bcc1334
feat: 实现生成任务后自动导出配置到任务目录的功能。
Dec 15, 2025
52b0164
chore: 删除不再使用的配置文件 S2.json, S3.json 和 S7-all.json,以清理项目结构
Dec 15, 2025
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
160 changes: 160 additions & 0 deletions .cursor/plans/重构_webui_模块化_32503828.plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
---
name: 重构 webui 模块化
overview: 将 webui.py(2134行)拆分为 webui/ 包,按职责划分为多个模块,保持原入口文件兼容。
todos: []
---

# 重构 webui.py 为模块化包

## 目标结构

```
webui/
├── __init__.py # 导出核心接口
├── constants.py # 常量、示例数据、方言配置
├── i18n.py # 国际化字典和函数
├── utils.py # 工具函数(类型转换、文本验证)
├── synthesis.py # 合成核心逻辑
├── file_manager.py # 文件保存、ZIP 创建
├── config_manager.py # 配置导入/导出
├── components.py # UI 组件创建
├── callbacks.py # UI 回调函数(说话人管理、语言切换等)
└── interface.py # render_interface 主函数

webui.py # 入口文件(保持兼容)
```

## 模块划分详情

### 1. `webui/constants.py`

- `BASE_DIR`, `CONFIG_DIR`, `MAX_SPEAKERS`, `MAX_TEXT_INPUTS`
- `S1_PROMPT_WAV`, `S2_PROMPT_WAV`
- `EXAMPLES_LIST`(第130-178行)
- `load_dialect_prompt_data()` 及 `DIALECT_PROMPT_DATA`, `DIALECT_CHOICES`

### 2. `webui/i18n.py`

- `_i18n_key2lang_dict`(约240行的翻译字典)
- `global_lang` 变量
- `i18n()` 函数
- `get_select_speaker_label()` 函数

### 3. `webui/utils.py`

- `_ensure_config_dir()`, `_list_config_files()`
- `_read_json_file()`, `_write_json_file()`
- `_coerce_gradio_file_to_path()`, `_coerce_audio_value_to_path()`
- `check_monologue_text()`, `check_dialect_prompt_text()`, `check_dialogue_text()`

### 4. `webui/synthesis.py`

- 全局变量 `model`, `dataset`
- `initiate_model()` 函数
- `process_single()` 函数
- `dialogue_synthesis_function()` 函数(核心合成逻辑,约280行)

### 5. `webui/file_manager.py`

- `create_zip_file()` 函数
- `create_all_zip()` 函数

### 6. `webui/config_manager.py`

- `_build_current_config_dict()` 函数
- `_export_current_config()` 函数
- `_refresh_config_dropdown()` 函数
- `_apply_loaded_config()` 函数
- `_load_uploaded_and_apply()` 函数
- `_load_selected_and_apply()` 函数

### 7. `webui/components.py`

- `create_speaker_group()` 函数
- `update_example_choices()`, `update_prompt_text()` 函数

### 8. `webui/callbacks.py`

- `update_speakers_visibility()` 函数
- `add_speaker()`, `quick_add_speakers()` 函数
- `batch_delete_speakers()` 函数
- `select_all_checkboxes()`, `select_none_checkboxes()` 函数
- `update_text_inputs_visibility()` 函数
- `process_single_synthesis()` 函数
- `collect_and_synthesize_queue()` 函数
- `_change_component_language()` 函数

### 9. `webui/interface.py`

- `render_interface()` 函数:仅保留 UI 布局定义,回调逻辑引用 `callbacks` 模块

### 10. `webui/__init__.py`

```python
from .interface import render_interface
from .synthesis import initiate_model
from .constants import BASE_DIR, CONFIG_DIR
```

### 11. `webui.py`(入口文件)

```python
from webui import render_interface, initiate_model
from webui.constants import ...
# 保持原有 get_args() 和 main 逻辑
```

## 模块依赖关系

```mermaid
flowchart TD
subgraph entry [Entry Point]
webui_py[webui.py]
end

subgraph pkg [webui package]
init[__init__.py]
interface[interface.py]
callbacks[callbacks.py]
components[components.py]
config_mgr[config_manager.py]
synthesis[synthesis.py]
file_mgr[file_manager.py]
utils[utils.py]
i18n[i18n.py]
constants[constants.py]
end

webui_py --> init
init --> interface
init --> synthesis

interface --> callbacks
interface --> components
interface --> config_mgr

callbacks --> synthesis
callbacks --> file_mgr
callbacks --> i18n

config_mgr --> utils
config_mgr --> constants

synthesis --> constants
synthesis --> i18n

components --> i18n

file_mgr --> i18n

utils --> constants
```

## 实施步骤

1. 创建 `webui/` 目录结构
2. 按依赖顺序创建模块(constants -> i18n -> utils -> 其他)
3. 迁移代码到各模块,调整 import 语句
4. 重构 `render_interface()`,将回调函数移至 `callbacks.py`
5. 更新 `webui.py` 为简洁入口
6. 验证功能正常
15 changes: 15 additions & 0 deletions .cursor/rules/python.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
alwaysApply: true
---
- 终端执行命令,优先使用bash。
- 运行 python 命令前,需要 先 激活python环境:
```python
# 初始化 conda 环境
source /root/anaconda3/etc/profile.d/conda.sh

# 激活环境
conda activate soulxpodcast

# 进入项目目录
cd /ygq/rag/workspace/my-Soul-Podcast/SoulX-Podcast
```
59 changes: 59 additions & 0 deletions config/Unit3-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"version": "1.0",
"export_time": "2025-12-14 18:12:31",
"language": "zh",
"num_speakers": 7,
"num_text_inputs": 4,
"seed": 1988,
"diff_spk_pause_ms": 0,
"speakers": [
{
"prompt_audio": "/tmp/gradio/9465bec06a6985197897d551638386080106fec488a16ce293cb3645fe3aa8b3/佩奇1 - 如果要骑到南瓜那儿那我们一定要非常小心千万不可以撞上去.mp3",
"prompt_text": "如果要骑到南瓜那儿,那我们一定要非常小心,千万不可以撞上去!",
"dialect_prompt_text": "",
"remark": "佩奇"
},
{
"prompt_audio": "/tmp/gradio/f2b287e0f747cdb9ea8ca421132c3518baba630ab72febb6f12cf25d43dfb66f/米小圈1.mp3",
"prompt_text": "这把钥匙一定很重要,失主到现在一定很着急。我按照字条上的地址来到一座山上,失主叔叔看到我把小盒子给他送回来高兴的都快哭了。",
"dialect_prompt_text": "",
"remark": "米小圈"
},
{
"prompt_audio": "/tmp/gradio/bf2dfc2b4940b4a9a565e980f6313e424a9f189cbda7905a26b1be0e1bd3858f/敖丙1.mp3",
"prompt_text": "五年多了,再次登台肯定还是有点儿,你不紧张吗?",
"dialect_prompt_text": "",
"remark": "敖丙"
},
{
"prompt_audio": "/tmp/gradio/a3065ccdb99a5cdefc540d8d2799478c75b684820dc8e37a7baeb8a79f7fee61/Amy1.mp3",
"prompt_text": "We're from the UK.\nWe're twins.",
"dialect_prompt_text": "",
"remark": "Amy"
},
{
"prompt_audio": "/tmp/gradio/02f81d423e5c2be7fafe5585692cd7407cdf7880fd8506556604c31e6806c17b/sam1.mp3",
"prompt_text": "Hi, everyone. I'm Sam.\nI'm nine.\nShe's Amy.\nShe's nine, too.",
"dialect_prompt_text": "",
"remark": "Sam"
},
{
"prompt_audio": "/tmp/gradio/435d41f664ea91565eb2a4531f168b99cd0e2123d9783051ac110f6176a0fdbe/daming1.mp3",
"prompt_text": "Sam, this is my dad.\nThis is my grandpa.\nThat is my grandma.\nBut who is that?\nOh, this is my grandma.",
"dialect_prompt_text": "",
"remark": "Ming"
},
{
"prompt_audio": "/tmp/gradio/34aebf28bbf889b39dc10b44b63640fdf43542dc08195dd3a9fd1b8ca42a1f05/Lingling1.mp3",
"prompt_text": "Hi, Sam.\nHi, Amy.\nI'm Ling Ling.\nHe's Da Ming.",
"dialect_prompt_text": "",
"remark": "Ling"
}
],
"text_inputs": [
"[S1] 一 <|pause:600|> 听力测试(共四节,满分60分)<|pause:2000|>\n[S2] 第一节:<|pause:600|>判断正误。(共10小题;每小题2分,满分20分)听录音,判断录音内容与下列图片是否一致?一致的请填“T”,不一致的请填“F”。每道题读三遍。<|pause:2000|>\n[S6] one, <|pause:1200|> N <|pause:1800|> N <|pause:1800|> N <|pause:2000|>\n[S4] two, <|pause:1200|> Let's see. <|pause:1800|> Let's see. <|pause:1800|> Let's see.<|pause:2000|>\n[S4] three, <|pause:1200|> Look at my umbrella. <|pause:1800|> Look at my umbrella. <|pause:1800|> Look at my umbrella.<|pause:2000|>\n[S4] four, <|pause:1200|> I want balloons. <|pause:1800|> I want balloons. <|pause:1800|> I want balloons.<|pause:2000|>\n[S4] five, <|pause:1200|> It's an orange orange. <|pause:1800|> It's an orange orange. <|pause:1800|> It's an orange orange.<|pause:2000|>\n[S4] six, <|pause:1200|> The rainbow is colourful! <|pause:1800|> The rainbow is colourful! <|pause:1800|> The rainbow is colourful!<|pause:2000|>\n[S4] seven, <|pause:1200|> Today is National Day. <|pause:1800|> Today is National Day. <|pause:1800|> Today is National Day.<|pause:2000|>\n[S4] eight, <|pause:1200|> So many colours! <|pause:1800|> So many colours! <|pause:1800|> So many colours!<|pause:2000|>\n[S4] nine, <|pause:1200|> What colours can you see? <|pause:1200|> [S5] I can see black and white.<|pause:1800|>[S4] What colours can you see? <|pause:1200|> [S5] I can see black and white.<|pause:1800|>[S4] What colours can you see? <|pause:1200|> [S5] I can see black and white.<|pause:2000|>\n[S4] ten, <|pause:1200|> Look! It's red now. <|pause:1800|> Look! It's red now. <|pause:1800|> Look! It's red now.<|pause:2000|>",
"[S3] 第二节:<|pause:600|>听音选图. (共10小题;每小题2分,满分20分)听录音,根据录音内容选择正确的图片。每道题读三遍。<|pause:2000|>\n[S6] eleven, <|pause:1200|> K <|pause:1800|> K <|pause:1800|> K <|pause:2000|>\n[S5] twelve, <|pause:1200|> What colour is it? <|pause:1200|> [S6] It's purple.<|pause:1800|>[S5] What colour is it? <|pause:1200|> [S6] It's purple.<|pause:1800|>[S5] What colour is it? <|pause:1200|> [S6] It's purple.<|pause:2000|>\n[S5] thirteen, <|pause:1200|> Let's come and paint. <|pause:1800|> Let's come and paint. <|pause:1800|> Let's come and paint.<|pause:2000|>\n[S5] fourteen, <|pause:1200|> It's green and red. <|pause:1800|> It's green and red. <|pause:1800|> It's green and red.<|pause:2000|>\n[S5] fifteen, <|pause:1200|> This is a colourful picture for the happy national day! <|pause:1800|> This is a colourful picture for the happy national day! <|pause:1800|> This is a colourful picture for the happy national day!<|pause:2000|>\n[S5] sixteen, <|pause:1200|> It's a picture. <|pause:1800|> It's a picture. <|pause:1800|> It's a picture.<|pause:2000|>\n[S5] seventeen, <|pause:1200|> Bobo is the first. <|pause:1800|> Bobo is the first. <|pause:1800|> Bobo is the first.<|pause:2000|>\n[S5] eighteen, <|pause:1200|> You are right. <|pause:1800|> You are right. <|pause:1800|> You are right.<|pause:2000|>\n[S5] nineteen, <|pause:1200|> What colours can you see? <|pause:1200|> [S7] I can see pink, red and green.<|pause:1800|>[S5] What colours can you see? <|pause:1200|> [S7] I can see pink, red and green.<|pause:1800|>[S5] What colours can you see? <|pause:1200|> [S7] I can see pink, red and green.<|pause:2000|>\n[S6] twenty, <|pause:1200|> L <|pause:1800|> L <|pause:1800|> L <|pause:2000|>",
"[S2] 第三节:<|pause:600|>听音选词. (共10小题;每小题1分,满分10分)听录音,根据录音内容选择正确的单词。每道题读三遍。<|pause:2000|>\n[S6] twenty one, <|pause:1200|> KMH <|pause:1800|> KMH <|pause:1800|> KMH <|pause:2000|>\n[S6] twenty two, <|pause:1200|> want <|pause:1800|> want <|pause:1800|> want <|pause:2000|>\n[S6] twenty three, <|pause:1200|> blue <|pause:1800|> blue <|pause:1800|> blue <|pause:2000|>\n[S6] twenty four, <|pause:1200|> purple <|pause:1800|> purple <|pause:1800|> purple <|pause:2000|>\n[S6] twenty five, <|pause:1200|> can <|pause:1800|> can <|pause:1800|> can <|pause:2000|>\n[S6] twenty six, <|pause:1200|> red <|pause:1800|> red <|pause:1800|> red <|pause:2000|>\n[S6] twenty seven, <|pause:1200|> world <|pause:1800|> world <|pause:1800|> world <|pause:2000|>\n[S6] twenty eight, <|pause:1200|> magical <|pause:1800|> magical <|pause:1800|> magical <|pause:2000|>\n[S6] twenty nine, <|pause:1200|> today <|pause:1800|> today <|pause:1800|> today <|pause:2000|>\n[S6] thirty, <|pause:1200|> fun <|pause:1800|> fun <|pause:1800|> fun <|pause:2000|>",
"[S3] 第四节:<|pause:600|> 听音辩句。(共10小题;每小题1分,满分10分)听录音,根据录音内容选出相应的句子。每道题读三遍。<|pause:2000|>\n[S7] thirty one, <|pause:1200|> Yellow and blue make green. <|pause:1800|> Yellow and blue make green. <|pause:1800|> Yellow and blue make green.<|pause:2000|>\n[S7] thirty two, <|pause:1200|> Red, yellow and blue make black. <|pause:1800|> Red, yellow and blue make black. <|pause:1800|> Red, yellow and blue make black.<|pause:2000|>\n[S7] thirty three, <|pause:1200|> Look at our clothes. <|pause:1800|> Look at our clothes. <|pause:1800|> Look at our clothes.<|pause:2000|>\n[S7] thirty four, <|pause:1200|> I'm yellow. <|pause:1800|> I'm yellow. <|pause:1800|> I'm yellow.<|pause:2000|>\n[S7] thirty five, <|pause:1200|> Come back. <|pause:1800|> Come back. <|pause:1800|> Come back.<|pause:2000|>\n[S7] thirty six, <|pause:1200|> What colour is it? <|pause:1800|> What colour is it? <|pause:1800|> What colour is it?<|pause:2000|>\n[S7] thirty seven, <|pause:1200|> It's a colourful world. <|pause:1800|> It's a colourful world. <|pause:1800|> It's a colourful world.<|pause:2000|>\n[S7] thirty eight, <|pause:1200|> This is fun <|pause:1800|> This is fun <|pause:1800|> This is fun <|pause:2000|>\n[S7] thirty nine, <|pause:1200|> I want a blue bag. <|pause:1800|> I want a blue bag. <|pause:1800|> I want a blue bag.<|pause:2000|>\n[S7] forty, <|pause:1200|> You are right. <|pause:1800|> You are right. <|pause:1800|> You are right.<|pause:2000|>"
]
}
Loading