Adding tiktok cause i hate my life
This commit is contained in:
parent
3a9cc068dd
commit
43d383626f
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user