diff options
| author | Samlon <stankiewiczgracjan2019@gmail.com> | 2025-08-12 21:11:23 +0200 |
|---|---|---|
| committer | Samlon <stankiewiczgracjan2019@gmail.com> | 2025-08-12 21:11:23 +0200 |
| commit | a7c330ab81e3d10f8a0c1a1af51db5721cc3a747 (patch) | |
| tree | 8dfceca2d2353da4eeb57b57604fb56e316968cd /cogs/tts.py | |
| parent | small vclogs change (diff) | |
| download | senator-sperma-a7c330ab81e3d10f8a0c1a1af51db5721cc3a747.tar.gz senator-sperma-a7c330ab81e3d10f8a0c1a1af51db5721cc3a747.zip | |
rework ai and tts
Diffstat (limited to '')
| -rw-r--r-- | cogs/tts.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cogs/tts.py b/cogs/tts.py index 8076a2d..07212ee 100644 --- a/cogs/tts.py +++ b/cogs/tts.py | |||
| @@ -8,7 +8,6 @@ import logging | |||
| 8 | 8 | ||
| 9 | logger = logging.getLogger(__name__) | 9 | logger = logging.getLogger(__name__) |
| 10 | 10 | ||
| 11 | |||
| 12 | class TTS(commands.Cog): | 11 | class TTS(commands.Cog): |
| 13 | def __init__(self, bot): | 12 | def __init__(self, bot): |
| 14 | self.bot = bot | 13 | self.bot = bot |
| @@ -20,14 +19,17 @@ class TTS(commands.Cog): | |||
| 20 | ): | 19 | ): |
| 21 | tts = gTTS(text=text, lang='pl') | 20 | tts = gTTS(text=text, lang='pl') |
| 22 | tts.save('tts.mp3') | 21 | tts.save('tts.mp3') |
| 22 | |||
| 23 | if output == "file": | 23 | if output == "file": |
| 24 | await ctx.respond(file=discord.File('tts.mp3')) | 24 | await ctx.respond(file=discord.File('tts.mp3')) |
| 25 | logger.info("TTS file sent") | 25 | logger.info("TTS file sent") |
| 26 | os.remove('tts.mp3') | 26 | os.remove('tts.mp3') |
| 27 | elif output == "vc": | 27 | elif output == "vc": |
| 28 | # Defer the response to avoid "Bot did not respond" message | ||
| 29 | await ctx.defer() | ||
| 30 | |||
| 28 | # Check if the user is in a voice channel | 31 | # Check if the user is in a voice channel |
| 29 | if not (ctx.author.voice and ctx.author.voice.channel): | 32 | if not (ctx.author.voice and ctx.author.voice.channel): |
| 30 | await ctx.respond("Musisz być na kanale głosowym, aby odtworzyć TTS!", ephemeral=True) | ||
| 31 | logger.info("User is not in a voice channel") | 33 | logger.info("User is not in a voice channel") |
| 32 | os.remove('tts.mp3') | 34 | os.remove('tts.mp3') |
| 33 | return | 35 | return |
| @@ -52,6 +54,5 @@ class TTS(commands.Cog): | |||
| 52 | logger.info("Unknown playback method") | 54 | logger.info("Unknown playback method") |
| 53 | os.remove('tts.mp3') | 55 | os.remove('tts.mp3') |
| 54 | 56 | ||
| 55 | |||
| 56 | def setup(bot): | 57 | def setup(bot): |
| 57 | bot.add_cog(TTS(bot)) | 58 | bot.add_cog(TTS(bot)) |
