From 8b3e9e821d138d9a6790cf89aceca377c1b67a72 Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Tue, 24 Oct 2023 22:56:25 +0800 Subject: [PATCH] fix: better mute xiaoai, fix: #331 --- xiaogpt/xiaogpt.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xiaogpt/xiaogpt.py b/xiaogpt/xiaogpt.py index 43888117..e94f04f9 100644 --- a/xiaogpt/xiaogpt.py +++ b/xiaogpt/xiaogpt.py @@ -100,9 +100,16 @@ async def poll_latest_ask(self): start = time.perf_counter() self.log.debug("Polling_event, timestamp: %s", self.last_timestamp) await self.polling_event.wait() + if ( + self.config.mute_xiaoai + and self.last_record + and self.need_ask_gpt(self.last_record) + ): + await self.stop_if_xiaoai_is_playing() if (d := time.perf_counter() - start) < 1: # sleep to avoid too many request self.log.debug("Sleep %f, timestamp: %s", d, self.last_timestamp) + # if you want force mute xiaoai, comment this line below. await asyncio.sleep(1 - d) async def init_all_data(self, session):