fixing tik tok
This commit is contained in:
parent
2b5facab40
commit
320bfb25a1
1
Makefile
1
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:
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user