Compare commits
No commits in common. "d89c98fea5be12608b7cc119e50d61fc0c2a8b50" and "d1d7d18bded5440d3114f05b5a40ed4a6b2345ae" have entirely different histories.
d89c98fea5
...
d1d7d18bde
13
DB.py
13
DB.py
@ -1,5 +1,3 @@
|
|||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import peewee
|
import peewee
|
||||||
|
|
||||||
database = peewee.SqliteDatabase('voice_cache.sqlite')
|
database = peewee.SqliteDatabase('voice_cache.sqlite')
|
||||||
@ -20,16 +18,5 @@ class Speaker(BaseModel):
|
|||||||
speaker = peewee.CharField()
|
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()
|
Prefix.create_table()
|
||||||
Speaker.create_table()
|
Speaker.create_table()
|
||||||
SynthesisErrors.create_table()
|
|
||||||
|
@ -11,5 +11,5 @@ class cogErrorHandlers:
|
|||||||
await ctx.reply(str(error))
|
await ctx.reply(str(error))
|
||||||
|
|
||||||
else:
|
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')
|
await ctx.reply(f'Internal error occurred')
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import Context
|
from discord.ext.commands import Context
|
||||||
import discord
|
import discord
|
||||||
@ -64,24 +62,10 @@ class TTSCommands(commands.Cog, Observ.Observer):
|
|||||||
|
|
||||||
speaker: Speakers = await self._get_speaker(message.guild.id)
|
speaker: Speakers = await self._get_speaker(message.guild.id)
|
||||||
|
|
||||||
# check if message will fail on synthesis
|
wav_file_like_object = self.tts.synthesize_text(message.content, speaker=speaker)
|
||||||
if DB.SynthesisErrors.select()\
|
sound_source = FFmpegPCMAudio(wav_file_like_object, pipe=True)
|
||||||
.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
|
|
||||||
|
|
||||||
try:
|
voice_client.play(sound_source)
|
||||||
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)
|
|
||||||
|
|
||||||
@commands.command('getAllSpeakers')
|
@commands.command('getAllSpeakers')
|
||||||
async def get_speakers(self, ctx: Context):
|
async def get_speakers(self, ctx: Context):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user