Skip to content

Commit

Permalink
feat: 新增 XIAOMUSIC_STOP_TTS_MSG 配置关机提示音
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Jun 30, 2024
1 parent 84751e0 commit a5b8dc6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions xiaomusic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(","):
Expand Down
5 changes: 3 additions & 2 deletions xiaomusic/xiaomusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ async def do_tts(self, value):
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():
Expand Down Expand Up @@ -871,7 +871,8 @@ async def play_music_list(self, **kwargs):
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("定时器已取消")
Expand Down

0 comments on commit a5b8dc6

Please sign in to comment.