自动播放机制

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

View File

@@ -2,6 +2,9 @@ import time
import pathlib
import toml
import typing
import playsound
import threading
import edge_tts as tts
class ConfigFile:
def __init__(self, path: str):
@@ -34,6 +37,17 @@ class ConfigFile:
"""获取配置值,如果不存在返回默认值"""
return self.data.get(key, default)
def action_play_voice(content):
def play():
communicate = tts.Communicate(
content,
"zh-CN-YunjianNeural",
)
communicate.save_sync(
f"./cache/voice/{content}"
)
playsound()
threading.Thread(target=play).start()
def get_daystamp() -> int:
"""获取当前日戳(以天为单位的整数时间戳)"""