|
|
@ -5,7 +5,9 @@ import os
|
|
|
|
import random
|
|
|
|
import random
|
|
|
|
import requests
|
|
|
|
import requests
|
|
|
|
from moviepy.editor import AudioFileClip, concatenate_audioclips, CompositeAudioClip
|
|
|
|
from moviepy.editor import AudioFileClip, concatenate_audioclips, CompositeAudioClip
|
|
|
|
|
|
|
|
#from profanity_filter import ProfanityFilter
|
|
|
|
|
|
|
|
#pf = ProfanityFilter()
|
|
|
|
|
|
|
|
# Code by @JasonLovesDoggo
|
|
|
|
# https://twitter.com/scanlime/status/1512598559769702406
|
|
|
|
# https://twitter.com/scanlime/status/1512598559769702406
|
|
|
|
nonhuman = [ # DISNEY VOICES
|
|
|
|
nonhuman = [ # DISNEY VOICES
|
|
|
|
'en_us_ghostface', # Ghost Face
|
|
|
|
'en_us_ghostface', # Ghost Face
|
|
|
@ -63,9 +65,11 @@ class TTTTSWrapper: # TikTok Text-to-Speech Wrapper
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
self.URI_BASE = 'https://api16-normal-useast5.us.tiktokv.com/media/api/text/speech/invoke/?text_speaker='
|
|
|
|
self.URI_BASE = 'https://api16-normal-useast5.us.tiktokv.com/media/api/text/speech/invoke/?text_speaker='
|
|
|
|
|
|
|
|
|
|
|
|
def tts(self, req_text: str = "TikTok Text To Speech", filename: str = 'title.mp3', random_speaker: bool = False):
|
|
|
|
def tts(self, req_text: str = "TikTok Text To Speech", filename: str = 'title.mp3', random_speaker: bool = False, censer=False):
|
|
|
|
req_text = req_text.replace("+", "plus").replace(" ", "+").replace("&", "and")
|
|
|
|
req_text = req_text.replace("+", "plus").replace(" ", "+").replace("&", "and")
|
|
|
|
|
|
|
|
if censer:
|
|
|
|
|
|
|
|
#req_text = pf.censor(req_text)
|
|
|
|
|
|
|
|
pass
|
|
|
|
voice = self.randomvoice() if random_speaker else (os.getenv('VOICE') or random.choice(human))
|
|
|
|
voice = self.randomvoice() if random_speaker else (os.getenv('VOICE') or random.choice(human))
|
|
|
|
|
|
|
|
|
|
|
|
chunks = [m.group().strip() for m in re.finditer(r' *((.{0,200})(\.|.$))', req_text)]
|
|
|
|
chunks = [m.group().strip() for m in re.finditer(r' *((.{0,200})(\.|.$))', req_text)]
|
|
|
|