Add more debug prints for TTSCore, separate try blocks for playing and synth
This commit is contained in:
parent
4b9f1cbad1
commit
c6c5d9c9a7
@ -78,19 +78,27 @@ class TTSCore(commands.Cog, Observ.Observer):
|
||||
try:
|
||||
wav_file_like_object = self.tts.synthesize_text(message.content, speaker=speaker)
|
||||
sound_source = FFmpegPCMAudio(wav_file_like_object, pipe=True, stderr=subprocess.PIPE)
|
||||
if voice_client.is_playing():
|
||||
# Then we need to enqueue prepared sound for playing through self.tts_queues mechanism
|
||||
|
||||
self.tts_queues[message.guild.id].append(sound_source)
|
||||
await message.channel.send(f"Enqueued for play, queue size: {len(self.tts_queues[message.guild.id])}")
|
||||
return
|
||||
|
||||
voice_client.play(sound_source, after=lambda e: self.queue_player(message))
|
||||
|
||||
except Exception as synth_exception:
|
||||
logger.opt(exception=True).warning(f'Exception on synthesize {message.content!r}: {synth_exception}')
|
||||
await message.channel.send(f'Internal error')
|
||||
await message.channel.send(f'Synthesize error')
|
||||
DB.SynthesisErrors.create(speaker=speaker.value, text=message.content)
|
||||
return
|
||||
|
||||
else:
|
||||
try:
|
||||
if voice_client.is_playing():
|
||||
# Then we need to enqueue prepared sound for playing through self.tts_queues mechanism
|
||||
self.tts_queues[message.guild.id].append(sound_source)
|
||||
await message.channel.send(f"Enqueued for play, queue size: {len(self.tts_queues[message.guild.id])}")
|
||||
return
|
||||
|
||||
voice_client.play(sound_source, after=lambda e: self.queue_player(message))
|
||||
|
||||
except Exception as play_exception:
|
||||
logger.opt(exception=True).warning(f'Exception on playing for: {message.guild.name}[#{message.channel.name}]: {message.author.display_name} / {play_exception}')
|
||||
await message.channel.send(f'Playing error')
|
||||
return
|
||||
|
||||
def queue_player(self, message: discord.Message):
|
||||
voice_client: Optional[discord.VoiceClient] = message.guild.voice_client
|
||||
@ -118,6 +126,8 @@ class TTSCore(commands.Cog, Observ.Observer):
|
||||
if members[0].id == self.bot.user.id:
|
||||
await before.channel.guild.voice_client.disconnect(force=False)
|
||||
|
||||
# TODO: leave voice channel after being moved there alone
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(TTSCore(bot))
|
||||
|
Loading…
x
Reference in New Issue
Block a user