自动播放机制

This commit is contained in:
2025-08-21 13:30:30 +08:00
parent 2c51f2cea3
commit cccf7189e3
4 changed files with 21 additions and 34 deletions

17
main.py
View File

@@ -22,18 +22,7 @@ import auxiliary as aux
import compositions as compo
import builtins
# Hook python 的 open() 函数, 使用 utf-8 (兼容 Windows 万年 GBK)
_original_open = builtins.open
def _open(*args, **kwargs):
if "encoding" not in kwargs:
kwargs["encoding"] = "utf-8"
return _original_open(*args, **kwargs)
builtins.open = _open
ver = "0.3.0"
ver = "0.3.1b"
config = aux.ConfigFile("config.toml")
@@ -62,6 +51,8 @@ class MemScreen(Screen):
self.compo = next(self.reactor.current_appar)
def compose(self) -> ComposeResult:
if type(self.compo).__name__ == "Recognition":
self.action_play_voice()
yield Header(show_clock=True)
with Center():
yield Static(
@@ -116,8 +107,10 @@ class MemScreen(Screen):
def refresh_ui(self):
self.call_later(self.recompose)
print(type(self.compo).__name__)
def action_play_voice(self):
print("VOICE")
def play():
cache_dir = pathlib.Path(f"./cache/voice/")
cache_dir.mkdir(parents=True, exist_ok=True)