Add logging for task generation and run ID retrieval in CambAI; enhance member name randomization in VoiceBot

This commit is contained in:
Edgar P. Burkhart 2025-03-23 12:04:59 +01:00
parent f101a02a99
commit e5d3c90e36
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 13 additions and 4 deletions

View file

@ -32,6 +32,7 @@ class CambAI:
return self.get_iostream(text, run_id)
def gen_task(self, text: str) -> str | None:
logger.info(f"Generating task for {text}.")
tts_payload = {
"text": text,
"voice_id": 20299,
@ -51,6 +52,7 @@ class CambAI:
return task_id
def get_runid(self, task_id: str | None) -> int | None:
logger.info(f"Getting runid for {task_id}.")
if task_id is None:
return None
@ -68,6 +70,7 @@ class CambAI:
return run_id
def get_iostream(self, text: str, run_id: int | None) -> pathlib.Path | None:
logger.info(f"Getting stream for {text} [{run_id}].")
if run_id is None:
return None

View file

@ -40,12 +40,12 @@ class VoiceBot:
async def random_connect(self) -> None:
while True:
logger.info("Random connect.")
for g_id in self.guild_ids:
guild = self.bot.get_guild(g_id)
if guild is None or random.random() > 10 / 100:
continue
logger.info("Random connect.")
voice_chan = random.choice(guild.voice_channels)
await self.connect_voice(voice_chan)
await asyncio.sleep(60)
@ -63,12 +63,14 @@ class VoiceBot:
await vo.disconnect()
return
elif len(channel.members) == 1:
member = channel.members[0].display_name
member = self.rnd_name(channel.members[0])
elif random.random() < 50 / 100:
member = self.rnd_name(random.choice(channel.members))
else:
member = (
", ".join(member.display_name for member in channel.members[:-1])
", ".join(self.rnd_name(member) for member in channel.members[:-1])
+ " et "
+ channel.members[-1].display_name
+ self.rnd_name(channel.members[-1])
)
script = None
@ -88,6 +90,10 @@ class VoiceBot:
await vo.play(source, wait_finish=True)
await vo.disconnect()
@classmethod
def rnd_name(cls, user: discord.Member) -> str:
return random.choice([user.display_name, user.name])
async def connect_voice_chan(
self, channel: discord.VoiceChannel | discord.StageChannel
) -> discord.VoiceClient: