Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,6 @@ import shutil
|
|
| 8 |
import re
|
| 9 |
import time
|
| 10 |
from tqdm import tqdm
|
| 11 |
-
import threading
|
| 12 |
|
| 13 |
# --- Coqui TTS 授权同意 ---
|
| 14 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
|
@@ -194,20 +193,14 @@ def generate_speech(text, language, uploaded_speaker_audio_path, speed=1.0, prog
|
|
| 194 |
output_file = fp.name
|
| 195 |
|
| 196 |
try:
|
| 197 |
-
# 实际生成语音
|
| 198 |
tts.tts_to_file(
|
| 199 |
text=text,
|
| 200 |
language=language,
|
| 201 |
speaker_wav=speaker_wav_to_use,
|
| 202 |
file_path=output_file,
|
| 203 |
-
#
|
| 204 |
-
speed=speed
|
| 205 |
-
temperature=0.7,
|
| 206 |
-
length_penalty=1.0,
|
| 207 |
-
top_p=0.85,
|
| 208 |
-
top_k=50,
|
| 209 |
-
encoder_sample_rate=16000,
|
| 210 |
-
decoder_sample_rate=16000
|
| 211 |
)
|
| 212 |
except Exception as e:
|
| 213 |
if output_file and os.path.exists(output_file):
|
|
@@ -403,7 +396,7 @@ with gr.Blocks(
|
|
| 403 |
if device == "cpu":
|
| 404 |
gr.Markdown("⚠️ **注意:** 当前使用CPU运行,XTTS-v2在CPU上运行会较慢。建议使用GPU以获得最佳性能。")
|
| 405 |
else:
|
| 406 |
-
gr.Markdown("✅ **GPU加速已启用** -
|
| 407 |
|
| 408 |
with gr.Tab("语音生成"):
|
| 409 |
with gr.Row():
|
|
@@ -417,7 +410,6 @@ with gr.Blocks(
|
|
| 417 |
)
|
| 418 |
with gr.Row():
|
| 419 |
speed_slider = gr.Slider(minimum=0.5, maximum=2.0, step=0.1, value=1.2, label="语速 (1.0为正常,>1.0加快)")
|
| 420 |
-
quality_slider = gr.Slider(minimum=0, maximum=1, step=1, value=0, label="质量模式 (0=速度优先, 1=质量优先)")
|
| 421 |
generate_button = gr.Button("生成语音", elem_classes="generate-button")
|
| 422 |
with gr.Column():
|
| 423 |
output_audio = gr.Audio(label="生成的语音", type="filepath")
|
|
|
|
| 8 |
import re
|
| 9 |
import time
|
| 10 |
from tqdm import tqdm
|
|
|
|
| 11 |
|
| 12 |
# --- Coqui TTS 授权同意 ---
|
| 13 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
|
|
|
| 193 |
output_file = fp.name
|
| 194 |
|
| 195 |
try:
|
| 196 |
+
# 实际生成语音 - 只使用支持的参数
|
| 197 |
tts.tts_to_file(
|
| 198 |
text=text,
|
| 199 |
language=language,
|
| 200 |
speaker_wav=speaker_wav_to_use,
|
| 201 |
file_path=output_file,
|
| 202 |
+
# 只使用支持的参数
|
| 203 |
+
speed=speed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
)
|
| 205 |
except Exception as e:
|
| 206 |
if output_file and os.path.exists(output_file):
|
|
|
|
| 396 |
if device == "cpu":
|
| 397 |
gr.Markdown("⚠️ **注意:** 当前使用CPU运行,XTTS-v2在CPU上运行会较慢。建议使用GPU以获得最佳性能。")
|
| 398 |
else:
|
| 399 |
+
gr.Markdown("✅ **GPU加速已启用** - 使用以下优化技术:半精度浮点数、模型编译")
|
| 400 |
|
| 401 |
with gr.Tab("语音生成"):
|
| 402 |
with gr.Row():
|
|
|
|
| 410 |
)
|
| 411 |
with gr.Row():
|
| 412 |
speed_slider = gr.Slider(minimum=0.5, maximum=2.0, step=0.1, value=1.2, label="语速 (1.0为正常,>1.0加快)")
|
|
|
|
| 413 |
generate_button = gr.Button("生成语音", elem_classes="generate-button")
|
| 414 |
with gr.Column():
|
| 415 |
output_audio = gr.Audio(label="生成的语音", type="filepath")
|