feat: 新增 XIAOMUSIC_STOP_TTS_MSG 配置关机提示音
This commit is contained in:
parent
84751e0d68
commit
a5b8dc639c
@ -88,6 +88,7 @@ class Config:
|
|||||||
enable_fuzzy_match: bool = (
|
enable_fuzzy_match: bool = (
|
||||||
os.getenv("XIAOMUSIC_ENABLE_FUZZY_MATCH", "true").lower() == "true"
|
os.getenv("XIAOMUSIC_ENABLE_FUZZY_MATCH", "true").lower() == "true"
|
||||||
)
|
)
|
||||||
|
stop_tts_msg: str = os.getenv("XIAOMUSIC_STOP_TTS_MSG", "收到,再见")
|
||||||
|
|
||||||
def append_keyword(self, keys, action):
|
def append_keyword(self, keys, action):
|
||||||
for key in keys.split(","):
|
for key in keys.split(","):
|
||||||
|
@ -291,7 +291,7 @@ class XiaoMusic:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error(f"Execption {e}")
|
self.log.error(f"Execption {e}")
|
||||||
# 最大等8秒
|
# 最大等8秒
|
||||||
sec = min(8, int(len(value) / 3.3))
|
sec = min(8, int(len(value) / 3))
|
||||||
await asyncio.sleep(sec)
|
await asyncio.sleep(sec)
|
||||||
self.log.debug(f"do_tts. cur_music:{self.cur_music}")
|
self.log.debug(f"do_tts. cur_music:{self.cur_music}")
|
||||||
if self._playing and not self.is_downloading():
|
if self._playing and not self.is_downloading():
|
||||||
@ -871,7 +871,8 @@ class XiaoMusic:
|
|||||||
async def stop(self, **kwargs):
|
async def stop(self, **kwargs):
|
||||||
self._playing = False
|
self._playing = False
|
||||||
if kwargs.get("arg1", "") != "notts":
|
if kwargs.get("arg1", "") != "notts":
|
||||||
await self.do_tts("收到指令,再见")
|
if self.config.stop_tts_msg:
|
||||||
|
await self.do_tts(self.config.stop_tts_msg)
|
||||||
if self._next_timer:
|
if self._next_timer:
|
||||||
self._next_timer.cancel()
|
self._next_timer.cancel()
|
||||||
self.log.info("定时器已取消")
|
self.log.info("定时器已取消")
|
||||||
|
Loading…
Reference in New Issue
Block a user