diff --git a/Makefile b/Makefile index b776097d..1168c0e6 100755 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ format: docker run --rm -ti -v ${PWD}:/tmp/python/app pyfound/black:latest_release sh -c "black /tmp/python" clean: + find . -name "*sync-conflict*" -print -delete docker rm -f dragon-bot-test build-test: diff --git a/app/cogs/cheeky_functions.py b/app/cogs/cheeky_functions.py index ad280c3d..263b6af9 100755 --- a/app/cogs/cheeky_functions.py +++ b/app/cogs/cheeky_functions.py @@ -19,7 +19,7 @@ class Cheeky(commands.Cog): all_voices = [] - url = "https://weilbyte.github.io/tiktok-tts/" + url = "https://tiktok-tts.weilbyte.dev/" response = requests.get(url) soup = BeautifulSoup(response.text, "html.parser") @@ -260,43 +260,74 @@ class Cheeky(commands.Cog): description="The text you want as TTS", max_length=300, ) - async def tiktok( - self, - ctx: commands.Context, - input: str, - voice: discord.Option( - str, - autocomplete=discord.utils.basic_autocomplete(get_all_voices), - description="Tiktok voice to use", - ), - ): + @option( + "voice", + description="The voice to use", + choices=[ + "en_us_001", + "en_us_006", + "en_us_007", + "en_us_009", + "en_us_010", + "en_uk_001", + "en_uk_003", + "en_au_001", + "en_au_002", + "en_us_ghostface", + "en_us_chewbacca", + "en_us_c3po", + "en_us_stitch", + "en_us_stormtrooper", + "en_us_rocket", + "en_female_f08_salut_damour", + "en_male_m03_lobby", + "en_male_m03_sunshine_soon", + "en_female_f08_warmy_breeze", + "en_female_ht_f08_glorious", + "en_male_sing_funny_it_goes_up", + "en_male_m2_xhxs_m03_silly", + "en_female_ht_f08_wonderful_world", + ], + required=True, + ) + async def tiktok(self, ctx: commands.Context, input: str, voice: str): import tempfile import base64 file, file_path = tempfile.mkstemp() headers = { + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0", + "Accept": "*/*", + "Accept-Language": "en-US,en;q=0.5", + # 'Accept-Encoding': 'gzip, deflate, br, zstd', "Content-Type": "application/json", + "Origin": "https://tiktok-tts.weilbyte.dev", + "DNT": "1", + "Connection": "keep-alive", + "Referer": "https://tiktok-tts.weilbyte.dev/", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-origin", + "Priority": "u=1", } - json_data = { - "text": input, - "voice": voice, - } + json_data = {"text": input, "voice": voice, "base64": True} + await ctx.defer() response = requests.post( - "https://tiktok-tts.weilnet.workers.dev/api/generation", + "https://tiktok-tts.weilbyte.dev/api/generate", headers=headers, json=json_data, - ).json() + ).text - audio_file = base64.b64decode(response["data"]) + audio_file = base64.b64decode(response) with open(file_path, "wb") as f: f.write(audio_file) f.close() os.rename(file_path, file_path + ".mp3") - await ctx.respond(file=discord.File(file_path + ".mp3")) + await ctx.send_followup(file=discord.File(file_path + ".mp3")) os.remove(file_path + ".mp3") @commands.slash_command(