Moved the character limit checker cause it was being buggy and making it so some longer comments went thru but not others and it looks like that's fixed now also deleted another character limit check cause it wasn't needed anymore. and for some reason the text replace thingy was in an if statement even tho I don't think it should have been in there.
pull/418/head
PatatjeMC 3 years ago
parent 14d3025407
commit d095391d35

@ -19,9 +19,6 @@ def main():
def get_obj():
reddit_obj = get_subreddit_threads()
for comment in (reddit_obj["comments"]):
if len(comment["comment_body"]) > 250:
reddit_obj["comments"].remove(comment)
return reddit_obj
reddit_object = get_obj()

@ -58,9 +58,10 @@ def get_subreddit_threads():
content["comments"] = []
for top_level_comment in submission.comments:
content["comments"].append(
{"comment_body": top_level_comment.body, "comment_url": top_level_comment.permalink,
"comment_id": top_level_comment.id, })
if len(top_level_comment.body) <= 250:
content["comments"].append(
{"comment_body": top_level_comment.body, "comment_url": top_level_comment.permalink,
"comment_id": top_level_comment.id, })
except AttributeError as e:
pass

@ -54,10 +54,7 @@ class TTTTSWrapper: # TikTok Text-to-Speech Wrapper
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):
if len(req_text) > 299:
return ValueError("Text too long must be under 299 characters")
if random_speaker:
req_text = req_text.replace("+", "plus").replace(" ", "+").replace("&", "and")
req_text = req_text.replace("+", "plus").replace(" ", "+").replace("&", "and")
voice = self.randomvoice() if random_speaker else 'en_us_002'
r = requests.post(f"{self.URI_BASE}{voice}&req_text={req_text}&speaker_map_type=0")

Loading…
Cancel
Save