Skip to content

Commit

Permalink
fix: better mute xiaoai, fix: #331
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong0618 committed Oct 24, 2023
1 parent 12158d5 commit 8b3e9e8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions xiaogpt/xiaogpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 8b3e9e8

Please sign in to comment.