自动播放机制
This commit is contained in:
14
auxiliary.py
14
auxiliary.py
@@ -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:
|
||||
"""获取当前日戳(以天为单位的整数时间戳)"""
|
||||
|
Reference in New Issue
Block a user