mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
lets do it manually then
This commit is contained in:
parent
dde0ce6ce7
commit
74b6b7026b
1 changed files with 13 additions and 9 deletions
|
@ -4,6 +4,7 @@ import os
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import time
|
||||||
import textwrap
|
import textwrap
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
@ -832,13 +833,16 @@ class OtherCog(commands.Cog):
|
||||||
|
|
||||||
async def callback(self, interaction: discord.Interaction):
|
async def callback(self, interaction: discord.Interaction):
|
||||||
def _convert(text: str) -> BytesIO():
|
def _convert(text: str) -> BytesIO():
|
||||||
with tempfile.NamedTemporaryFile(suffix=".mp3") as temp:
|
target_fn = f"jimmy-tts-{ctx.user.id}-{ctx.interaction.id}.mp3"
|
||||||
engine = pyttsx3.init()
|
engine = pyttsx3.init()
|
||||||
_io = BytesIO()
|
_io = BytesIO()
|
||||||
engine.save_to_file(text, temp.name)
|
engine.save_to_file(text, target_fn)
|
||||||
engine.runAndWait()
|
engine.runAndWait()
|
||||||
with open(temp.name, "rb") as f:
|
while not os.path.exists(target_fn):
|
||||||
|
time.sleep(0.5)
|
||||||
|
with open(target_fn, "rb") as f:
|
||||||
_io.write(f.read())
|
_io.write(f.read())
|
||||||
|
os.remove(target_fn)
|
||||||
_io.seek(0)
|
_io.seek(0)
|
||||||
return _io
|
return _io
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue