From 03b94f61318675f1df83d384670b506a0df6e118 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 20 May 2026 15:37:14 +0200 Subject: Fix TTS and AI voice playback bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - tts.py _handle_voice_output: add missing voice_client.play() call via VoiceManager.play_source() — was creating the audio source and then doing nothing - ai.py: use VoiceManager.play_source() instead of passing an FFmpegPCMAudio object to play() which expects a string path --- cogs/tts.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'cogs/tts.py') diff --git a/cogs/tts.py b/cogs/tts.py index 68eb27f..ca81d3a 100644 --- a/cogs/tts.py +++ b/cogs/tts.py @@ -42,28 +42,26 @@ class TTS(commands.Cog): await ctx.respond(content="\u200b", ephemeral=True) await ctx.interaction.delete_original_response() - # Check if the user is in a voice channel if not (ctx.author.voice and ctx.author.voice.channel): logger.info("User is not in a voice channel") return channel = ctx.author.voice.channel try: - voice_client = await self._get_or_connect_voice_client(channel) + voice_mgr = self._get_voice_manager() - if not voice_client: - await ctx.respond("Failed to connect to voice channel", ephemeral=True) - return - - if voice_client.is_playing(): - await ctx.respond("Audio is already playing, try again later", ephemeral=True) - return + if voice_mgr.get_voice_client and await voice_mgr.get_client(channel.guild): + vc = await voice_mgr.get_client(channel.guild) + if vc and vc.is_playing(): + logger.info("Audio already playing, skipping TTS") + return audio_source = discord.FFmpegPCMAudio( temp_path, options=f'-filter:a "volume={volume}"' ) logger.info(f"Playing TTS: {text}") + await voice_mgr.play_source(channel, audio_source) except Exception as e: logger.error(f"Error in voice channel handling: {e}") -- cgit v1.2.3