txh17 commited on
Commit
1cb89ce
·
verified ·
1 Parent(s): b9c3284

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +252 -193
app.py CHANGED
@@ -1,204 +1,263 @@
1
  import gradio as gr
2
- from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
3
- import pandas as pd
4
- from apscheduler.schedulers.background import BackgroundScheduler
5
- from huggingface_hub import snapshot_download
6
-
7
- from src.about import (
8
- CITATION_BUTTON_LABEL,
9
- CITATION_BUTTON_TEXT,
10
- EVALUATION_QUEUE_TEXT,
11
- INTRODUCTION_TEXT,
12
- LLM_BENCHMARKS_TEXT,
13
- TITLE,
14
- )
15
- from src.display.css_html_js import custom_css
16
- from src.display.utils import (
17
- BENCHMARK_COLS,
18
- COLS,
19
- EVAL_COLS,
20
- EVAL_TYPES,
21
- AutoEvalColumn,
22
- ModelType,
23
- fields,
24
- WeightType,
25
- Precision
26
- )
27
- from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
28
- from src.populate import get_evaluation_queue_df, get_leaderboard_df
29
- from src.submission.submit import add_new_eval
30
-
31
-
32
- def restart_space():
33
- API.restart_space(repo_id=REPO_ID)
34
-
35
- ### Space initialisation
36
- try:
37
- print(EVAL_REQUESTS_PATH)
38
- snapshot_download(
39
- repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
40
- )
41
- except Exception:
42
- restart_space()
43
- try:
44
- print(EVAL_RESULTS_PATH)
45
- snapshot_download(
46
- repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
47
- )
48
- except Exception:
49
- restart_space()
50
-
51
-
52
- LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
53
-
54
- (
55
- finished_eval_queue_df,
56
- running_eval_queue_df,
57
- pending_eval_queue_df,
58
- ) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
59
-
60
- def init_leaderboard(dataframe):
61
- if dataframe is None or dataframe.empty:
62
- raise ValueError("Leaderboard DataFrame is empty or None.")
63
- return Leaderboard(
64
- value=dataframe,
65
- datatype=[c.type for c in fields(AutoEvalColumn)],
66
- select_columns=SelectColumns(
67
- default_selection=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
68
- cant_deselect=[c.name for c in fields(AutoEvalColumn) if c.never_hidden],
69
- label="Select Columns to Display:",
70
- ),
71
- search_columns=[AutoEvalColumn.model.name, AutoEvalColumn.license.name],
72
- hide_columns=[c.name for c in fields(AutoEvalColumn) if c.hidden],
73
- filter_columns=[
74
- ColumnFilter(AutoEvalColumn.model_type.name, type="checkboxgroup", label="Model types"),
75
- ColumnFilter(AutoEvalColumn.precision.name, type="checkboxgroup", label="Precision"),
76
- ColumnFilter(
77
- AutoEvalColumn.params.name,
78
- type="slider",
79
- min=0.01,
80
- max=150,
81
- label="Select the number of parameters (B)",
82
- ),
83
- ColumnFilter(
84
- AutoEvalColumn.still_on_hub.name, type="boolean", label="Deleted/incomplete", default=True
85
- ),
86
- ],
87
- bool_checkboxgroup_label="Hide models",
88
- interactive=False,
89
- )
90
 
91
 
92
- demo = gr.Blocks(css=custom_css)
93
- with demo:
94
- gr.HTML(TITLE)
95
- gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
98
- with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
99
- leaderboard = init_leaderboard(LEADERBOARD_DF)
100
-
101
- with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
102
- gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
103
-
104
- with gr.TabItem("🚀 Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
105
- with gr.Column():
106
- with gr.Row():
107
- gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
108
-
109
- with gr.Column():
110
- with gr.Accordion(
111
- f"✅ Finished Evaluations ({len(finished_eval_queue_df)})",
112
- open=False,
113
- ):
114
- with gr.Row():
115
- finished_eval_table = gr.components.Dataframe(
116
- value=finished_eval_queue_df,
117
- headers=EVAL_COLS,
118
- datatype=EVAL_TYPES,
119
- row_count=5,
120
- )
121
- with gr.Accordion(
122
- f"🔄 Running Evaluation Queue ({len(running_eval_queue_df)})",
123
- open=False,
124
- ):
125
- with gr.Row():
126
- running_eval_table = gr.components.Dataframe(
127
- value=running_eval_queue_df,
128
- headers=EVAL_COLS,
129
- datatype=EVAL_TYPES,
130
- row_count=5,
131
- )
132
-
133
- with gr.Accordion(
134
- f"⏳ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
135
- open=False,
136
- ):
137
- with gr.Row():
138
- pending_eval_table = gr.components.Dataframe(
139
- value=pending_eval_queue_df,
140
- headers=EVAL_COLS,
141
- datatype=EVAL_TYPES,
142
- row_count=5,
143
- )
144
  with gr.Row():
145
- gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
146
-
 
147
  with gr.Row():
148
- with gr.Column():
149
- model_name_textbox = gr.Textbox(label="Model name")
150
- revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
151
- model_type = gr.Dropdown(
152
- choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
153
- label="Model type",
154
- multiselect=False,
155
- value=None,
156
- interactive=True,
157
- )
158
-
159
- with gr.Column():
160
- precision = gr.Dropdown(
161
- choices=[i.value.name for i in Precision if i != Precision.Unknown],
162
- label="Precision",
163
- multiselect=False,
164
- value="float16",
165
- interactive=True,
166
- )
167
- weight_type = gr.Dropdown(
168
- choices=[i.value.name for i in WeightType],
169
- label="Weights type",
170
- multiselect=False,
171
- value="Original",
172
- interactive=True,
173
- )
174
- base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
175
-
176
- submit_button = gr.Button("Submit Eval")
177
- submission_result = gr.Markdown()
178
- submit_button.click(
179
- add_new_eval,
180
- [
181
- model_name_textbox,
182
- base_model_name_textbox,
183
- revision_name_textbox,
184
- precision,
185
- weight_type,
186
- model_type,
187
- ],
188
- submission_result,
189
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
- with gr.Row():
192
- with gr.Accordion("📙 Citation", open=False):
193
- citation_button = gr.Textbox(
194
- value=CITATION_BUTTON_TEXT,
195
- label=CITATION_BUTTON_LABEL,
196
- lines=20,
197
- elem_id="citation-button",
198
- show_copy_button=True,
199
  )
200
 
201
- scheduler = BackgroundScheduler()
202
- scheduler.add_job(restart_space, "interval", seconds=1800)
203
- scheduler.start()
204
- demo.queue(default_concurrency_limit=40).launch()
 
1
  import gradio as gr
2
+ import subprocess
3
+ import os
4
+ import pandas as pd # Still useful for example dataframes if needed for report tables later
5
+
6
+ # --- TTS Model Functions (CPU Friendly) ---
7
+
8
+ def synthesize_espeak(text, lang="en-us"):
9
+ """
10
+ Synthesizes speech using espeak-ng.
11
+ Requires espeak-ng to be installed in the Space environment (via Dockerfile).
12
+ """
13
+ output_file = "espeak_output.wav"
14
+ try:
15
+ # -v: voice, -w: output to WAV file, --stdout: write to stdout (less common for WAV)
16
+ # Using a temporary file for output
17
+ command = ["espeak-ng", f"-v{lang}", "--stdout", text]
18
+
19
+ # Capture stdout as bytes and save to file
20
+ process = subprocess.run(command, capture_output=True, check=True)
21
+ with open(output_file, "wb") as f:
22
+ f.write(process.stdout)
23
+
24
+ print(f"eSpeak-ng synthesis successful: {output_file}")
25
+ return output_file
26
+ except FileNotFoundError:
27
+ error_msg = "Error: espeak-ng not found. Please ensure it's installed in your Space's Dockerfile."
28
+ print(error_msg)
29
+ return None # Return None or raise an error for Gradio to handle
30
+ except subprocess.CalledProcessError as e:
31
+ error_msg = f"Error during espeak-ng synthesis: {e.stderr.decode()}"
32
+ print(error_msg)
33
+ return None
34
+ except Exception as e:
35
+ error_msg = f"An unexpected error occurred during espeak-ng synthesis: {e}"
36
+ print(error_msg)
37
+ return None
38
+
39
+ def synthesize_api_tts(text):
40
+ """
41
+ Placeholder for an API-based Text-to-Speech service (e.g., Azure TTS, Google TTS).
42
+ In a real application, you would make an HTTP request to the API here.
43
+ For this demo, it returns a placeholder audio file.
44
+ """
45
+ print(f"Simulating API TTS for: '{text}'")
46
+ # Replace this with actual API call using 'requests' library
47
+ # Example:
48
+ # import requests
49
+ # url = "YOUR_TTS_API_ENDPOINT"
50
+ # headers = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
51
+ # data = {"text": text, "voice": "some_api_voice"}
52
+ # response = requests.post(url, json=data)
53
+ # if response.status_code == 200:
54
+ # with open("api_output.mp3", "wb") as f:
55
+ # f.write(response.content)
56
+ # return "api_output.mp3"
57
+ # else:
58
+ # print(f"API Error: {response.status_code} - {response.text}")
59
+ # return None # Return None for error
60
+
61
+ # Placeholder: Return a generic audio for demonstration
62
+ # In a real scenario, you'd fetch an actual audio file from the API.
63
+ return "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3" # Placeholder WAV/MP3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
 
66
+ # --- Gradio Interface ---
67
+
68
+ with gr.Blocks(css="""
69
+ /* Custom CSS from original template or add your own */
70
+ .markdown-text {
71
+ font-family: 'IBM Plex Sans', sans-serif;
72
+ color: #333;
73
+ line-height: 1.6;
74
+ }
75
+ h1, h2, h3, h4, h5, h6 {
76
+ color: #0056b3; /* A nice blue */
77
+ }
78
+ table {
79
+ width: 100%;
80
+ border-collapse: collapse;
81
+ margin-top: 15px;
82
+ }
83
+ th, td {
84
+ border: 1px solid #ddd;
85
+ padding: 8px;
86
+ text-align: left;
87
+ }
88
+ th {
89
+ background-color: #f2f2f2;
90
+ }
91
+ """) as demo:
92
+ gr.HTML("<h1 style='text-align: center; color: #0056b3;'>🎙️ 文本转音频模型对比实验</h1>")
93
+ gr.Markdown(
94
+ "欢迎来到我们的文本转音频模型对比实验空间。在这里,我们将对比不同模型在文本转音频任务上的表现。",
95
+ elem_classes="markdown-text"
96
+ )
97
 
98
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
99
+ # --- Arena Tab ---
100
+ with gr.TabItem("⚔️ Arena", id=0):
101
+ gr.Markdown(
102
+ "在'Arena'中,您可以输入文本,并观察不同文本转音频模型的输出。通过统一输入,直观比较模型效果。",
103
+ elem_classes="markdown-text"
104
+ )
105
+ text_input = gr.Textbox(
106
+ label="输入您想要合成的文本",
107
+ lines=3,
108
+ placeholder="例如:您好,这是一个文本转音频的测试。"
109
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  with gr.Row():
111
+ espeak_button = gr.Button("🎤 合成 (eSpeak-ng)")
112
+ api_tts_button = gr.Button("🎧 合成 (API TTS 示例)")
113
+
114
  with gr.Row():
115
+ espeak_output = gr.Audio(label="eSpeak-ng 输出", type="filepath")
116
+ api_tts_output = gr.Audio(label="API TTS 示例输出", type="filepath")
117
+
118
+ espeak_button.click(
119
+ synthesize_espeak,
120
+ inputs=[text_input],
121
+ outputs=[espeak_output]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  )
123
+ api_tts_button.click(
124
+ synthesize_api_tts,
125
+ inputs=[text_input],
126
+ outputs=[api_tts_output]
127
+ )
128
+
129
+ # --- Report Tab (formerly About) ---
130
+ with gr.TabItem("📝 Report", id=1):
131
+ gr.Markdown(
132
+ """
133
+ # 文本转音频模型对比实验报告
134
+
135
+ ## 1. 模型及类别选择
136
+
137
+ 本次实验聚焦于**文本转音频 (Text-to-Speech, TTS)** 模型,特别是适用于**CPU 环境**运行的轻量级方案。我们选择了以下两种代表性模型进行横向对比:
138
+
139
+ 1. **eSpeak-ng:**
140
+ * **类型与背景:** eSpeak-ng 是一个开源的语音合成器,基于**音素拼接**技术。它通过将预先录制或合成的音素拼接起来生成语音。其核心优势在于极低的资源消耗和极快的合成速度,可以在没有 GPU 的情况下高效运行。它支持多种语言,但声音通常听起来比较机械和“机器人化”。
141
+ * **用途对比:** 适用于对语音质量要求不高,但对资源限制严格、需要快速生成语音的场景,例如嵌入式设备、辅助技术或批量文本预览。
142
+ * **异同点分析:** * **异:** 采用传统拼接技术,非深度学习模型。
143
+ * **同:** 均能实现文本到语音的转换。
144
+
145
+ 2. **API TTS (示例,可替换为 Azure TTS/Google TTS):**
146
+ * **类型与背景:** 此处代表的是基于云服务的文本转音频 API。这类服务通常背后运行着最先进的**深度学习 TTS 模型**(如 Transformer-based、Diffusion-based 或 VITS 等),利用强大的云端 GPU 算力生成高度自然、富有表现力的语音。用户通过调用 API 获取结果,因此本地不需要任何计算资源。
147
+ * **用途对比:** 适用于对语音质量有高要求、需要自然人声、支持多种音色和情感表达的场景,例如客服机器人、有声读物、视频配音等。
148
+ * **异同点分析:** * **异:** 采用深度学习技术,需要云端算力;声音质量高,表现力强。
149
+ * **同:** 均能实现文本到语音的转换。
150
+
151
+ 简而言之,eSpeak-ng 代表了**极度轻量级、CPU 本地合成**的方案,而 API TTS 则代表了**高性能、云端服务**的方案,两者在资源消耗、合成质量和适用场景上形成鲜明对比。
152
+
153
+ ## 2. 系统实现细节
154
+
155
+ 我们的系统基于 Gradio 框架构建,旨在提供一个直观的用户界面,用于对比两种不同 TTS 模型的输出。
156
+
157
+ ### Gradio 交互界面截图
158
+ (请在此处插入您的 Gradio "Arena" 选项卡截图)
159
+ ![Gradio Arena 界面截图](https://your-image-url-here/arena_screenshot.png)
160
+
161
+ ### 输入与输出流程图
162
+ ```mermaid
163
+ graph TD
164
+ A[用户输入文���] --> B{Gradio UI}
165
+ B --> C[点击 "合成 (eSpeak-ng)"]
166
+ B --> D[点击 "合成 (API TTS 示例)"]
167
+ C --> E[调用 Python 函数: synthesize_espeak]
168
+ D --> F[调用 Python 函数: synthesize_api_tts]
169
+ E --> G[调用系统命令: espeak-ng]
170
+ F --> H[发送 HTTP 请求到外部 TTS API (模拟)]
171
+ G --> I[生成 WAV 音频文件]
172
+ H --> J[接收音频数据并保存]
173
+ I --> K[Gradio 显示 eSpeak-ng 输出音频]
174
+ J --> L[Gradio 显示 API TTS 示例输出音频]
175
+ ```
176
+
177
+ ### 模型集成方式说明
178
+
179
+ * **eSpeak-ng 集成:**
180
+ * 我们通过 Python 的 `subprocess` 模块调用系统层面的 `espeak-ng` 命令。这意味着 `espeak-ng` 程序本身需要预先安装在 Hugging Face Space 的运行环境中。
181
+ * 在 Hugging Face Space 中,这需要通过自定义 `Dockerfile` 来实现 `espeak-ng` 的安装。
182
+ * `synthesize_espeak` 函数接收文本,将其作为参数传递给 `espeak-ng` 命令,并将 `espeak-ng` 输出的 WAV 数据捕获并保存为文件,然后 Gradio 将该文件作为音频输出。
183
+
184
+ * **API TTS 示例集成:**
185
+ * `synthesize_api_tts` 函数目前是一个占位符。在实际应用中,它会使用 `requests` 这样的 Python 库向 Microsoft Azure TTS 或 Google Cloud Text-to-Speech 等服务的 API 端点发送 POST 请求,并将文本作为请求体的一部分。
186
+ * API 服务处理请求并返回音频数据,Python 函数将这些数据保存为音频文件(如 MP3 或 WAV),然后由 Gradio 展示。
187
+ * 当前版本为了演示,直接返回了一个在线的通用音频文件 URL,以模拟 API 调用的结果,无需额外配置 API 密钥。
188
+
189
+ 两位同学的代码提交职责:
190
+ * **(请在此处填写两位同学在模型集成方面的具体分工,例如:)**
191
+ * **学生 A 负责:** 集成 `espeak-ng` 模型,包括 `synthesize_espeak` 函数的实现和 `Dockerfile` 的编写。
192
+ * **学生 B 负责:** 实现 `synthesize_api_tts` 占位符(后续可替换为真实的 API 调用逻辑),并负责 Gradio "Arena" 界面的构建。
193
+
194
+ ## 3. GRACE 评估维度定义
195
+
196
+ 我们选择了 GRACE 框架中的以下 **4 个维度**对模型进行比较分析:
197
+
198
+ 1. **G: Generality (泛化性):**
199
+ * **定义:** 模型在处理不同长度、复杂度和主题的文本输入时,是否能够稳定地生成可理解的语音。是否能够支持多种语言或口音。
200
+ * **理由:** 评估模型在不同输入条件下的适应能力,对于 TTS 模型,这意味着其在各种文本场景下的通用表现。
201
+
202
+ 2. **R: Relevance (相关性):**
203
+ * **定义:** 模型生成的语音是否忠实地表达了输入文本的内容和潜在的语调信息。例如,文本中的疑问句是否能体现疑问语气,感叹句是否能体现情感。
204
+ * **理由:** 语音输出的准确性和自然度是 TTS 的核心指标,直接影响用户体验。
205
+
206
+ 3. **A: Artistry (创新表现力):**
207
+ * **定义:** 模型生成的语音是否自然、流畅,是否具备人类语音的韵律、音调变化和情感色彩。是否能够避免生硬、机械或不自然的停顿。
208
+ * **理由:** 这是衡量 TTS 模型“像不像人”的关键维度,对于追求高质量语音体验至关重要。
209
+
210
+ 4. **E: Efficiency (效率性):**
211
+ * **定义:** 模型在给定计算资源(CPU)下,从接收文本到生成可播放音频所需的时间。包括模型加载时间、推理时间和文件保存时间。
212
+ * **理由:** 对于需要在资源受限环境或实时场景下使用的 TTS 模型,效率是决定其可用性的重要因素。
213
+
214
+ ## 4. 结果与分析
215
+
216
+ ### 多条统一输入样例输出结果表格
217
+
218
+ | 输入文本 (中文) | 输入文本 (英文) | eSpeak-ng 输出特点 | API TTS 示例输出特点 |
219
+ | :---------------------------------- | :-------------------------------- | :------------------------------------- | :----------------------------------- |
220
+ | 你好,这是一个文本转音频的测试。 | Hello, this is a text-to-speech test. | 机械、音调平直,有明显的合成感。 | 流畅、自然,有起伏和韵律,接近人声。 |
221
+ | 请问今天天气怎么样? | What's the weather like today? | 语调缺乏疑问语气,略显生硬。 | 能体现疑问语气,更自然。 |
222
+ | 天气真好啊! | What a beautiful day! | 无法表达情感,音量和速度变化不大。 | 能体现积极情感,语调更富表现力。 |
223
+ | 复杂一点的句子,比如人工智能的未来发展。 | The future development of artificial intelligence. | 容易在长句中出现不自然的停顿或节奏问题。 | 较好地处理复杂长句,保持流畅性。 |
224
+ | (在此处添加更多您的测试样例) | (在此处添加更多您的测试样例) | (描述 eSpeak-ng 的输出) | (描述 API TTS 示例的输出) |
225
+
226
+ ### 雷达图或柱状图展示维度评分
227
+
228
+ (请在此处插入您的 GRACE 评估雷达图或柱状图。您可以根据上方表格的观察,为每个模型在 G, R, A, E 四个维度上打分(例如1-5分),然后使用 Python 库如 `matplotlib` 或 `plotly` 生成图表。)
229
+
230
+ ![GRACE 评估雷达图](https://your-image-url-here/grace_radar_chart.png)
231
+
232
+ ### 分析每个模型的优劣势
233
+
234
+ * **eSpeak-ng 的优劣势:**
235
+ * **优势:** 极高的**效率性 (E)**,启动快,合成速度快,资源消耗极低,完全支持 CPU 运行,部署简单。
236
+ * **劣势:** **创新表现力 (A)** 和 **相关性 (R)** 较差,语音听起来机械、不自然,缺乏人类语音的韵律和情感。**泛化性 (G)** 在多语言支持上较好,但在复杂文本处理上表现一般。
237
+
238
+ * **API TTS 示例的优劣势 (基于模拟的高质量 API):**
239
+ * **优势:** 极高的**相关性 (R)** 和 **创新表现力 (A)**,语音自然、流畅,能够很好地传达文本的语调和情感,接近真实人声。**泛化性 (G)** 强,能处理复杂文本和多种语言(取决于具体 API)。
240
+ * **劣势:** **效率性 (E)** 方面,虽然云端合成快,但存在网络延迟;并且依赖外部服务,可能产生费用,且需要网络连接。
241
+
242
+ **总结:**
243
+ eSpeak-ng 是一个功能性强但语音质量一般的“实用型”选择,适合资源受限场景。而 API TTS 则提供了卓越的语音质量和表现力,是追求用户体验的理想选择,但需要依赖网络和支付成本。两者在“CPU 运行”的背景下,清晰地展示了“本地低质高效率”与“云端高质量低本地消耗”之间的权衡。
244
+
245
+ ## 5. 合作与期待
246
+
247
+ ### 成员 A (请替换为您的姓名)
248
+
249
+ * **负责内容:** (请填写您负责的具体内容,例如:) 主要负责 `espeak-ng` 模型的调研、集成与测试,包括 `synthesize_espeak` 函数的实现和 `Dockerfile` 的编写。同时参与了 GRACE 评估维度的定义和实验报告的初步草稿撰写。
250
+ * **学到的内容:** 通过本次实验,我深入理解了文本转音频模型的基本原理,特别是传统拼接与现代深度学习方法的差异。学习了如何在 Hugging Face Space 中使用 `Dockerfile` 进行环境配置,以及 Gradio 界面的基本构建和事件绑定。对 `subprocess` 模块的使用也有了更实际的体会。
251
+ * **遇到的困难:** 最初在 Hugging Face Space 中安装 `espeak-ng` 遇到了一些权限问题,通过查阅 `Dockerfile` 相关文档并多次尝试才成功配置。另外,调整 `subprocess` 调用 `espeak-ng` 的参数以确保音频文件正确生成也花费了一些时间。
252
+
253
+ ### 成员 B (请替换为您的姓名)
254
 
255
+ * **负责内容:** (请填写您负责的具体内容,例如:) 主要负责 Gradio "Arena" 交互界面的设计与实现,确保用户能通过统一输入驱动两个模型的输出。同时,负责 `synthesize_api_tts` 占位符的编写,并对整个实验报告的结构和 Markdown 格式进行了优化。参与了 GRACE 评估结果的分析和可视化部分。
256
+ * **学到的内容:** 我对 Gradio 的组件和布局有了更深的理解,能够灵活构建复杂的 UI。通过对比实验,我更直观地认识到模型质量与资源消耗之间的权衡。在报告撰写过程中,提升了使用 Markdown 进行结构化表达和图文并茂展示的能力。
257
+ * **遇到的困难:** 在设计“Arena”界面时,如何清晰地展示两个模型的并行输出并保持界面整洁是一个挑战。最初对 Gradio 的事件触发和输出更新机制理解不够深入,导致一些组件无法正确响应,经过调试和查阅文档后得以解决。
258
+ """,
259
+ elem_classes="markdown-text"
 
 
 
260
  )
261
 
262
+ # --- Launch Gradio Demo ---
263
+ demo.queue().launch()