Compare commits

..

No commits in common. "d89c98fea5be12608b7cc119e50d61fc0c2a8b50" and "d1d7d18bded5440d3114f05b5a40ed4a6b2345ae" have entirely different histories.

3 changed files with 4 additions and 33 deletions

13
DB.py
View File

@ -1,5 +1,3 @@
from datetime import datetime
import peewee
database = peewee.SqliteDatabase('voice_cache.sqlite')
@ -20,16 +18,5 @@ class Speaker(BaseModel):
speaker = peewee.CharField()
class SynthesisErrors(peewee.Model):
speaker = peewee.CharField()
text = peewee.TextField()
timestamp = peewee.DateTimeField(default=datetime.now)
class Meta:
database = database
primary_key = peewee.CompositeKey('speaker', 'text')
Prefix.create_table()
Speaker.create_table()
SynthesisErrors.create_table()

View File

@ -11,5 +11,5 @@ class cogErrorHandlers:
await ctx.reply(str(error))
else:
logger.exception(f'Command error occurred: ', exc_info=error)
logger.exception(f'prefixConfiguration error occurred: ', exc_info=error)
await ctx.reply(f'Internal error occurred')

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
import subprocess
from discord.ext import commands
from discord.ext.commands import Context
import discord
@ -64,24 +62,10 @@ class TTSCommands(commands.Cog, Observ.Observer):
speaker: Speakers = await self._get_speaker(message.guild.id)
# check if message will fail on synthesis
if DB.SynthesisErrors.select()\
.where(DB.SynthesisErrors.speaker == speaker.value)\
.where(DB.SynthesisErrors.text == message.content)\
.count() == 1:
# Then we will not try to synthesis it
await message.channel.send(f"I will not synthesis this message due to TTS engine limitations")
return
wav_file_like_object = self.tts.synthesize_text(message.content, speaker=speaker)
sound_source = FFmpegPCMAudio(wav_file_like_object, pipe=True)
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)
voice_client.play(sound_source)
except Exception as synth_exception:
logger.warning(f'Exception on synthesize {message.content!r}: {synth_exception}', exc_info=synth_exception)
await message.channel.send(f'Internal error')
DB.SynthesisErrors.create(speaker=speaker.value, text=message.content)
voice_client.play(sound_source)
@commands.command('getAllSpeakers')
async def get_speakers(self, ctx: Context):