Spaces:
Running
Running
Commit
·
3fb07cc
1
Parent(s):
7aff86a
(wip)file cache as md5
Browse files
app.py
CHANGED
|
@@ -347,7 +347,7 @@ def init_predefined_texts_and_prompts():
|
|
| 347 |
print(f"加载预置文本出错: {e}")
|
| 348 |
predefined_texts = []
|
| 349 |
|
| 350 |
-
# 处理预置prompt
|
| 351 |
predefined_prompts = {}
|
| 352 |
try:
|
| 353 |
# 从reference_audio_files中筛选10个作为预置prompt
|
|
@@ -355,8 +355,10 @@ def init_predefined_texts_and_prompts():
|
|
| 355 |
selected_prompts = random.sample(reference_audio_files, min(10, len(reference_audio_files)))
|
| 356 |
for i, prompt_path in enumerate(selected_prompts):
|
| 357 |
prompt_name = f"preset_prompt_{i + 1}"
|
| 358 |
-
|
| 359 |
-
|
|
|
|
|
|
|
| 360 |
print(f"设置了 {len(predefined_prompts)} 个预置prompt音频")
|
| 361 |
except Exception as e:
|
| 362 |
print(f"设置预置prompt音频出错: {e}")
|
|
@@ -1217,7 +1219,7 @@ def setup_periodic_tasks():
|
|
| 1217 |
scheduler.add_job(sync_database, "interval", minutes=15, id="sync_db_job")
|
| 1218 |
# Sync preferences more frequently
|
| 1219 |
scheduler.add_job(sync_preferences_data, "interval", minutes=5, id="sync_pref_job")
|
| 1220 |
-
scheduler.add_job(sync_cache_audios_with_hf, "interval", minutes=
|
| 1221 |
scheduler.start()
|
| 1222 |
print("Periodic tasks scheduler started (DB sync and Preferences upload)") # Use print for startup
|
| 1223 |
|
|
|
|
| 347 |
print(f"加载预置文本出错: {e}")
|
| 348 |
predefined_texts = []
|
| 349 |
|
| 350 |
+
# 处理预置prompt音频,值为文件md5
|
| 351 |
predefined_prompts = {}
|
| 352 |
try:
|
| 353 |
# 从reference_audio_files中筛选10个作为预置prompt
|
|
|
|
| 355 |
selected_prompts = random.sample(reference_audio_files, min(10, len(reference_audio_files)))
|
| 356 |
for i, prompt_path in enumerate(selected_prompts):
|
| 357 |
prompt_name = f"preset_prompt_{i + 1}"
|
| 358 |
+
# 计算文件md5
|
| 359 |
+
with open(prompt_path, 'rb') as f:
|
| 360 |
+
prompt_md5 = hashlib.md5(f.read()).hexdigest()
|
| 361 |
+
predefined_prompts[prompt_name] = prompt_md5
|
| 362 |
print(f"设置了 {len(predefined_prompts)} 个预置prompt音频")
|
| 363 |
except Exception as e:
|
| 364 |
print(f"设置预置prompt音频出错: {e}")
|
|
|
|
| 1219 |
scheduler.add_job(sync_database, "interval", minutes=15, id="sync_db_job")
|
| 1220 |
# Sync preferences more frequently
|
| 1221 |
scheduler.add_job(sync_preferences_data, "interval", minutes=5, id="sync_pref_job")
|
| 1222 |
+
scheduler.add_job(sync_cache_audios_with_hf, "interval", minutes=5, id="sync_cache_audio_job")
|
| 1223 |
scheduler.start()
|
| 1224 |
print("Periodic tasks scheduler started (DB sync and Preferences upload)") # Use print for startup
|
| 1225 |
|