aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/tts.py
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-20 15:37:14 +0200
committersalmonik <raisersoft@proton.me>2026-05-20 15:37:14 +0200
commit03b94f61318675f1df83d384670b506a0df6e118 (patch)
tree79c179cd43a2a419670bd85d9f966215a37f8179 /cogs/tts.py
parentFold AudioPlaybackManager into VoiceManager + Future-based play (diff)
downloadsenator-sperma-03b94f61318675f1df83d384670b506a0df6e118.tar.gz
senator-sperma-03b94f61318675f1df83d384670b506a0df6e118.zip
Fix TTS and AI voice playback bugs
- 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
Diffstat (limited to '')
-rw-r--r--cogs/tts.py16
1 files changed, 7 insertions, 9 deletions
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):
42 await ctx.respond(content="\u200b", ephemeral=True) 42 await ctx.respond(content="\u200b", ephemeral=True)
43 await ctx.interaction.delete_original_response() 43 await ctx.interaction.delete_original_response()
44 44
45 # Check if the user is in a voice channel
46 if not (ctx.author.voice and ctx.author.voice.channel): 45 if not (ctx.author.voice and ctx.author.voice.channel):
47 logger.info("User is not in a voice channel") 46 logger.info("User is not in a voice channel")
48 return 47 return
49 48
50 channel = ctx.author.voice.channel 49 channel = ctx.author.voice.channel
51 try: 50 try:
52 voice_client = await self._get_or_connect_voice_client(channel) 51 voice_mgr = self._get_voice_manager()
53 52
54 if not voice_client: 53 if voice_mgr.get_voice_client and await voice_mgr.get_client(channel.guild):
55 await ctx.respond("Failed to connect to voice channel", ephemeral=True) 54 vc = await voice_mgr.get_client(channel.guild)
56 return 55 if vc and vc.is_playing():
57 56 logger.info("Audio already playing, skipping TTS")
58 if voice_client.is_playing(): 57 return
59 await ctx.respond("Audio is already playing, try again later", ephemeral=True)
60 return
61 58
62 audio_source = discord.FFmpegPCMAudio( 59 audio_source = discord.FFmpegPCMAudio(
63 temp_path, 60 temp_path,
64 options=f'-filter:a "volume={volume}"' 61 options=f'-filter:a "volume={volume}"'
65 ) 62 )
66 logger.info(f"Playing TTS: {text}") 63 logger.info(f"Playing TTS: {text}")
64 await voice_mgr.play_source(channel, audio_source)
67 65
68 except Exception as e: 66 except Exception as e:
69 logger.error(f"Error in voice channel handling: {e}") 67 logger.error(f"Error in voice channel handling: {e}")