allow user-controlled speed

This commit is contained in:
Nexus 2023-03-16 23:49:37 +00:00
parent de8550ee84
commit b8073fe290

View file

@ -814,8 +814,18 @@ class OtherCog(commands.Cog):
@commands.slash_command(name="text-to-mp3") @commands.slash_command(name="text-to-mp3")
@commands.cooldown(5, 600, commands.BucketType.user) @commands.cooldown(5, 600, commands.BucketType.user)
async def text_to_mp3(self, ctx: discord.ApplicationContext): async def text_to_mp3(
self,
ctx: discord.ApplicationContext,
speed: discord.Option(
int,
"The speed of the voice. Default is 150.",
required=False,
default=150
)
):
"""Converts text to MP3. 5 uses per 10 minutes.""" """Converts text to MP3. 5 uses per 10 minutes."""
speed = min(300, max(100, speed))
_bot = self.bot _bot = self.bot
class TextModal(discord.ui.Modal): class TextModal(discord.ui.Modal):
def __init__(self): def __init__(self):
@ -836,7 +846,7 @@ class OtherCog(commands.Cog):
_bot.console.log("Starting pyttsx3") _bot.console.log("Starting pyttsx3")
engine = pyttsx3.init() engine = pyttsx3.init()
# engine.setProperty("voice", "english-north") # engine.setProperty("voice", "english-north")
engine.setProperty("rate", 150) engine.setProperty("rate", speed)
_io = BytesIO() _io = BytesIO()
_bot.console.log("Saving to file") _bot.console.log("Saving to file")
engine.save_to_file(text, target_fn) engine.save_to_file(text, target_fn)