Spaces:
Running
Running
Commit
·
7ad77d2
1
Parent(s):
014ee4b
update check cache
Browse files
app.py
CHANGED
@@ -676,19 +676,19 @@ def generate_tts():
|
|
676 |
valid_pairs = []
|
677 |
# 枚举所有模型对,找到第一个都通过的组合
|
678 |
for i in range(len(candidate_models)):
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
|
|
|
|
683 |
model_b = candidate_models[j]
|
684 |
-
audio_a_path = find_cached_audio(str(model_a.id), text, reference_audio_path)
|
685 |
audio_b_path = find_cached_audio(str(model_b.id), text, reference_audio_path)
|
686 |
-
if
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
app.logger.warning(f"Found valid model pair: {model_a.name} and {model_b.name} for text '{text[:50]}...'")
|
692 |
if not valid_pairs:
|
693 |
return jsonify({"error": "所有模型均未通过持久化缓存和静音检测,无法生成音频"}), 500
|
694 |
|
|
|
676 |
valid_pairs = []
|
677 |
# 枚举所有模型对,找到第一个都通过的组合
|
678 |
for i in range(len(candidate_models)):
|
679 |
+
model_a = candidate_models[i]
|
680 |
+
audio_a_path = find_cached_audio(str(model_a.id), text, reference_audio_path)
|
681 |
+
if not os.path.exists(audio_a_path) or has_long_silence(audio_a_path):
|
682 |
+
continue
|
683 |
+
# 检测到a模型音频有效,继续检测b模型
|
684 |
+
for j in range(i + 1, len(candidate_models)):
|
685 |
model_b = candidate_models[j]
|
|
|
686 |
audio_b_path = find_cached_audio(str(model_b.id), text, reference_audio_path)
|
687 |
+
if not os.path.exists(audio_b_path) or has_long_silence(audio_b_path):
|
688 |
+
continue
|
689 |
+
valid_pairs.append((model_a, audio_a_path, model_b, audio_b_path))
|
690 |
+
app.logger.warning(f"Found valid model pair: {model_a.name} and {model_b.name} for text '{text[:50]}...'")
|
691 |
+
break
|
|
|
692 |
if not valid_pairs:
|
693 |
return jsonify({"error": "所有模型均未通过持久化缓存和静音检测,无法生成音频"}), 500
|
694 |
|