From 6aff23ac18a6b156d9731aed6865a0d87c71e7c5 Mon Sep 17 00:00:00 2001 From: Luke Robles <98352913+lrobles-iterable@users.noreply.github.com> Date: Tue, 17 Jan 2023 13:50:41 -0800 Subject: [PATCH] Adding tiktok cause i hate my life --- app/cogs/cheeky_functions.py | 42 ++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/app/cogs/cheeky_functions.py b/app/cogs/cheeky_functions.py index 9fd707c6..abaea7b2 100755 --- a/app/cogs/cheeky_functions.py +++ b/app/cogs/cheeky_functions.py @@ -4,6 +4,7 @@ import core_utils import discord import random import requests +import os class Cheeky(commands.Cog): @@ -151,14 +152,51 @@ class Cheeky(commands.Cog): "https://paypal.me/ldooks\nhttps://venmo.com/ldooks\nhttps://cash.me/$ldooks" ) - @commands.command(name="nft") + @commands.slash_command( + guild_ids=None, + name="tiktok", + description="Returns a god awful tts with the tiktok voice", + ) + @option(name="input", required=True, description="The text you want as TTS") + async def tiktok(self, ctx: commands.Context, input): + + import tempfile + import base64 + + file, file_path = tempfile.mkstemp() + + headers = { + "Content-Type": "application/json", + } + + json_data = { + "text": input, + "voice": "en_us_001", + } + + response = requests.post( + "https://tiktok-tts.weilnet.workers.dev/api/generation", + headers=headers, + json=json_data, + ).json() + + audio_file = base64.b64decode(response["data"]) + 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")) + os.remove(file_path + ".mp3") + + @commands.slash_command(guild_ids=None, name="nft", description="Returns an nft") async def nft(self, ctx: commands.Context): import nft result = nft.get_nft() - await ctx.reply(result) + await ctx.respond(result) @commands.slash_command( guild_ids=None, name="8ball", description="Ask the magic 8 ball a question"