性能改进

This commit is contained in:
2025-10-07 23:30:16 +08:00
parent d71d8eb1ec
commit ebeb62f72d

View File

@@ -19,7 +19,6 @@ from textual.screen import Screen
from textual.worker import Worker, get_current_worker from textual.worker import Worker, get_current_worker
import pathlib import pathlib
import threading import threading
import edge_tts as tts
from playsound import playsound from playsound import playsound
import particles as pt import particles as pt
from reactor import Reactor, Apparatus, Glimpse from reactor import Reactor, Apparatus, Glimpse
@@ -95,6 +94,7 @@ class PrecachingScreen(Screen):
cache = cache_dir / f"{aux.get_md5(text)}.wav" cache = cache_dir / f"{aux.get_md5(text)}.wav"
if not cache.exists(): if not cache.exists():
try: try:
import edge_tts as tts
communicate = tts.Communicate(text, "zh-CN-XiaoxiaoNeural") communicate = tts.Communicate(text, "zh-CN-XiaoxiaoNeural")
communicate.save_sync(str(cache)) communicate.save_sync(str(cache))
return True return True
@@ -330,6 +330,7 @@ class MemScreen(Screen):
cache_dir.mkdir(parents=True, exist_ok=True) cache_dir.mkdir(parents=True, exist_ok=True)
cache = cache_dir / f"{aux.get_md5(self.reactor.current_atom[1].content.replace('/',''))}.wav" cache = cache_dir / f"{aux.get_md5(self.reactor.current_atom[1].content.replace('/',''))}.wav"
if not cache.exists(): if not cache.exists():
import edge_tts as tts
communicate = tts.Communicate( communicate = tts.Communicate(
self.reactor.current_atom[1].content.replace("/", ""), self.reactor.current_atom[1].content.replace("/", ""),
"zh-CN-XiaoxiaoNeural", "zh-CN-XiaoxiaoNeural",