return a list of all possible voices for the tiktok command
This commit is contained in:
parent
ebc0c4c9c3
commit
8c20bf160c
@ -1,16 +1,39 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
from discord import option
|
from discord import option
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import core_utils
|
import core_utils
|
||||||
import discord
|
import discord
|
||||||
|
import os
|
||||||
import random
|
import random
|
||||||
import requests
|
import requests
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
class Cheeky(commands.Cog):
|
class Cheeky(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot: commands.Bot = bot
|
self.bot: commands.Bot = bot
|
||||||
|
|
||||||
|
async def get_all_voices(ctx: discord.AutocompleteContext):
|
||||||
|
"""
|
||||||
|
returns a list of all voices you can pass to the API
|
||||||
|
"""
|
||||||
|
|
||||||
|
all_voices = []
|
||||||
|
|
||||||
|
url = "https://weilbyte.github.io/tiktok-tts/"
|
||||||
|
response = requests.get(url)
|
||||||
|
|
||||||
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
|
|
||||||
|
all_voices = [
|
||||||
|
item.get("value")
|
||||||
|
for item in soup.find(
|
||||||
|
"select",
|
||||||
|
class_="rounded p-1 bg-slate-100 mt-2 w-full sm:w-1/2",
|
||||||
|
).select("option[value]")
|
||||||
|
]
|
||||||
|
|
||||||
|
return sorted(set(all_voices))
|
||||||
|
|
||||||
@commands.slash_command(
|
@commands.slash_command(
|
||||||
guild_ids=None,
|
guild_ids=None,
|
||||||
name="decide",
|
name="decide",
|
||||||
@ -177,7 +200,16 @@ class Cheeky(commands.Cog):
|
|||||||
description="The text you want as TTS",
|
description="The text you want as TTS",
|
||||||
max_length=300,
|
max_length=300,
|
||||||
)
|
)
|
||||||
async def tiktok(self, ctx: commands.Context, input: str):
|
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",
|
||||||
|
),
|
||||||
|
):
|
||||||
import tempfile
|
import tempfile
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
@ -189,7 +221,7 @@ class Cheeky(commands.Cog):
|
|||||||
|
|
||||||
json_data = {
|
json_data = {
|
||||||
"text": input,
|
"text": input,
|
||||||
"voice": "en_us_001",
|
"voice": voice,
|
||||||
}
|
}
|
||||||
|
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user