Add voices

This commit is contained in:
Nexus 2023-03-20 14:48:23 +00:00
parent 8d3159f71b
commit ffb6f51fed
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -34,6 +34,11 @@ from selenium.webdriver.firefox.service import Service as FirefoxService
from utils import console
_engine = pyttsx3.init()
# noinspection PyTypeChecker
VOICES = [x.id for x in _engine.getProperty("voices")]
del _engine
# noinspection DuplicatedCode
class OtherCog(commands.Cog):
@ -822,6 +827,12 @@ class OtherCog(commands.Cog):
"The speed of the voice. Default is 150.",
required=False,
default=150
),
voice: discord.Option(
str,
"The voice to use. Some may cause timeout.",
choices=VOICES,
default="default"
)
):
"""Converts text to MP3. 5 uses per 10 minutes."""
@ -848,7 +859,7 @@ class OtherCog(commands.Cog):
target_fn = Path(tmp_dir) / f"jimmy-tts-{ctx.user.id}-{ctx.interaction.id}.mp3"
target_fn = str(target_fn)
engine = pyttsx3.init()
# engine.setProperty("voice", "english-north")
engine.setProperty("voice", voice)
engine.setProperty("rate", speed)
_io = BytesIO()
engine.save_to_file(text, target_fn)