diff options
| author | salmonik <salmonik@noreply.codeberg.org> | 2026-04-19 18:10:09 +0200 |
|---|---|---|
| committer | salmonik <salmonik@noreply.codeberg.org> | 2026-04-19 18:10:09 +0200 |
| commit | f8e1cf36e1efa0602bf2e450835f2a67654762a6 (patch) | |
| tree | fe6b12226d7eebe2a0dc6525de3414d0c3718cc8 /cogs/tts.py | |
| parent | add support for x^2+y^2=0,4 and alike (diff) | |
| parent | fix: proper aiohttp async context manager mocking in test (diff) | |
| download | senator-sperma-f8e1cf36e1efa0602bf2e450835f2a67654762a6.tar.gz senator-sperma-f8e1cf36e1efa0602bf2e450835f2a67654762a6.zip | |
Merge pull request 'massive changes' (#3) from dev into main
Reviewed-on: https://codeberg.org/salmonik/senator-sperma/pulls/3
stable enough
Diffstat (limited to '')
| -rw-r--r-- | cogs/tts.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/cogs/tts.py b/cogs/tts.py index 3dc4c09..68eb27f 100644 --- a/cogs/tts.py +++ b/cogs/tts.py | |||
| @@ -54,19 +54,17 @@ class TTS(commands.Cog): | |||
| 54 | if not voice_client: | 54 | if not voice_client: |
| 55 | await ctx.respond("Failed to connect to voice channel", ephemeral=True) | 55 | await ctx.respond("Failed to connect to voice channel", ephemeral=True) |
| 56 | return | 56 | return |
| 57 | 57 | ||
| 58 | # Play the TTS audio with volume adjustment | 58 | if voice_client.is_playing(): |
| 59 | await ctx.respond("Audio is already playing, try again later", ephemeral=True) | ||
| 60 | return | ||
| 61 | |||
| 59 | audio_source = discord.FFmpegPCMAudio( | 62 | audio_source = discord.FFmpegPCMAudio( |
| 60 | temp_path, | 63 | temp_path, |
| 61 | options=f'-filter:a "volume={volume}"' | 64 | options=f'-filter:a "volume={volume}"' |
| 62 | ) | 65 | ) |
| 63 | voice_client.play(audio_source) | ||
| 64 | logger.info(f"Playing TTS: {text}") | 66 | logger.info(f"Playing TTS: {text}") |
| 65 | 67 | ||
| 66 | # Wait for the audio to finish playing | ||
| 67 | while voice_client.is_playing(): | ||
| 68 | await asyncio.sleep(0.1) | ||
| 69 | |||
| 70 | except Exception as e: | 68 | except Exception as e: |
| 71 | logger.error(f"Error in voice channel handling: {e}") | 69 | logger.error(f"Error in voice channel handling: {e}") |
| 72 | await ctx.respond("eror :c", ephemeral=True) | 70 | await ctx.respond("eror :c", ephemeral=True) |
