From a5b8dc639cfd6ae63f41f6f879707406a9d74733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Sun, 30 Jun 2024 07:32:33 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20XIAOMUSIC=5FSTOP?= =?UTF-8?q?=5FTTS=5FMSG=20=E9=85=8D=E7=BD=AE=E5=85=B3=E6=9C=BA=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/config.py | 1 + xiaomusic/xiaomusic.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xiaomusic/config.py b/xiaomusic/config.py index fa41197..3d9ab4f 100644 --- a/xiaomusic/config.py +++ b/xiaomusic/config.py @@ -88,6 +88,7 @@ class Config: enable_fuzzy_match: bool = ( 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): for key in keys.split(","): diff --git a/xiaomusic/xiaomusic.py b/xiaomusic/xiaomusic.py index 51e787a..116e2ea 100644 --- a/xiaomusic/xiaomusic.py +++ b/xiaomusic/xiaomusic.py @@ -291,7 +291,7 @@ class XiaoMusic: except Exception as e: self.log.error(f"Execption {e}") # 最大等8秒 - sec = min(8, int(len(value) / 3.3)) + sec = min(8, int(len(value) / 3)) await asyncio.sleep(sec) self.log.debug(f"do_tts. cur_music:{self.cur_music}") if self._playing and not self.is_downloading(): @@ -871,7 +871,8 @@ class XiaoMusic: async def stop(self, **kwargs): self._playing = False 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: self._next_timer.cancel() self.log.info("定时器已取消")