diff --git a/GUI/settings.html b/GUI/settings.html index 1f0ef2e..f3f1751 100644 --- a/GUI/settings.html +++ b/GUI/settings.html @@ -205,7 +205,7 @@ @@ -618,4 +618,4 @@ }); -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index 7a73d61..6d498d2 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -14,14 +14,12 @@ from utils import settings from utils.console import print_step, print_substep from utils.voice import sanitize_text - DEFAULT_MAX_LENGTH: int = ( 50 # Video length variable, edit this on your own risk. It should work, but it's not supported ) class TTSEngine: - """Calls the given TTS engine to reduce code duplication and allow multiple TTS engines. Args: diff --git a/TTS/streamlabs_polly.py b/TTS/streamlabs_polly.py index 9ecabf4..aca1fe3 100644 --- a/TTS/streamlabs_polly.py +++ b/TTS/streamlabs_polly.py @@ -43,8 +43,8 @@ class StreamlabsPolly: f"Please set the config variable STREAMLABS_POLLY_VOICE to a valid voice. options are: {voices}" ) voice = str(settings.config["settings"]["tts"]["streamlabs_polly_voice"]).capitalize() + headers = {"referer": "https://streamlabs.com"} body = {"voice": voice, "text": text, "service": "polly"} - headers = {"Referer" : "https://streamlabs.com/" } response = requests.post(self.url, headers=headers, data=body) if not check_ratelimit(response): self.run(text, filepath, random_voice) diff --git a/main.py b/main.py index efaa51c..0a401c3 100755 --- a/main.py +++ b/main.py @@ -7,11 +7,13 @@ from subprocess import Popen from typing import NoReturn from prawcore import ResponseException -from utils.console import print_substep + from reddit.subreddit import get_subreddit_threads from utils import settings from utils.cleanup import cleanup from utils.console import print_markdown, print_step +from utils.console import print_substep +from utils.ffmpeg_install import ffmpeg_install from utils.id import id from utils.version import checkversion from video_creation.background import ( @@ -23,7 +25,6 @@ from video_creation.background import ( from video_creation.final_video import make_final_video from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts from video_creation.voices import save_text_to_mp3 -from utils.ffmpeg_install import ffmpeg_install __VERSION__ = "3.2.1" diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 419cf79..5f2ac5f 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -1,18 +1,16 @@ import re -from prawcore.exceptions import ResponseException - -from utils import settings import praw from praw.models import MoreComments from prawcore.exceptions import ResponseException +from utils import settings +from utils.ai_methods import sort_by_similarity from utils.console import print_step, print_substep +from utils.posttextparser import posttextparser from utils.subreddit import get_subreddit_undone from utils.videos import check_done from utils.voice import sanitize_text -from utils.posttextparser import posttextparser -from utils.ai_methods import sort_by_similarity def get_subreddit_threads(POST_ID: str): diff --git a/requirements.txt b/requirements.txt index c9abc85..f804029 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ boto3==1.26.142 botocore==1.29.142 -gTTS==2.3.2 +gTTS==2.5.1 moviepy==1.0.3 playwright==1.34.0 praw==7.7.0 @@ -10,14 +10,14 @@ rich==13.4.1 toml==0.10.2 translators==5.7.6 pyttsx3==2.90 -Pillow==9.5.0 +Pillow==10.2.0 tomlkit==0.11.8 Flask==2.3.3 clean-text==0.6.0 -unidecode==1.3.6 +unidecode==1.3.8 spacy==3.5.3 -torch==2.0.1 -transformers==4.29.2 +torch==2.2.0 +transformers==4.37.2 ffmpeg-python==0.2.0 elevenlabs==0.2.17 yt-dlp==2023.7.6 \ No newline at end of file diff --git a/utils/.config.template.toml b/utils/.config.template.toml index accf86d..211cc97 100644 --- a/utils/.config.template.toml +++ b/utils/.config.template.toml @@ -44,7 +44,7 @@ background_thumbnail_font_color = { optional = true, default = "255,255,255", ex [settings.tts] voice_choice = { optional = false, default = "tiktok", options = ["elevenlabs", "streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", ], example = "tiktok", explanation = "The voice platform used for TTS generation. " } -random_voice = { optional = false, default = true, example = true, options = [true, false,], explanation = "Randomizes the voice used for each comment" } +random_voice = { optional = false, type = "bool", default = true, example = true, options = [true, false,], explanation = "Randomizes the voice used for each comment" } elevenlabs_voice_name = { optional = false, default = "Bella", example = "Bella", explanation = "The voice used for elevenlabs", options = ["Adam", "Antoni", "Arnold", "Bella", "Domi", "Elli", "Josh", "Rachel", "Sam", ] } elevenlabs_api_key = { optional = true, example = "21f13f91f54d741e2ae27d2ab1b99d59", explanation = "Elevenlabs API key" } aws_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for AWS Polly" } diff --git a/utils/ai_methods.py b/utils/ai_methods.py index ed1d559..eb6e73e 100644 --- a/utils/ai_methods.py +++ b/utils/ai_methods.py @@ -1,6 +1,6 @@ import numpy as np -from transformers import AutoTokenizer, AutoModel import torch +from transformers import AutoTokenizer, AutoModel # Mean Pooling - Take attention mask into account for correct averaging diff --git a/utils/cleanup.py b/utils/cleanup.py index 6e00d4c..8c73b15 100644 --- a/utils/cleanup.py +++ b/utils/cleanup.py @@ -1,6 +1,6 @@ import os -from os.path import exists import shutil +from os.path import exists def _listdir(d): # listdir with full path diff --git a/utils/ffmpeg_install.py b/utils/ffmpeg_install.py index 7d5b3ad..b2c673d 100644 --- a/utils/ffmpeg_install.py +++ b/utils/ffmpeg_install.py @@ -1,7 +1,8 @@ -import zipfile -import requests import os import subprocess +import zipfile + +import requests def ffmpeg_install_windows(): @@ -39,7 +40,10 @@ def ffmpeg_install_windows(): # Rename and move files os.rename(f"{ffmpeg_extracted_folder}-6.0-full_build", ffmpeg_extracted_folder) for file in os.listdir(os.path.join(ffmpeg_extracted_folder, "bin")): - os.rename(os.path.join(ffmpeg_extracted_folder, "bin", file), os.path.join(".", file)) + os.rename( + os.path.join(ffmpeg_extracted_folder, "bin", file), + os.path.join(".", file), + ) os.rmdir(os.path.join(ffmpeg_extracted_folder, "bin")) for file in os.listdir(os.path.join(ffmpeg_extracted_folder, "doc")): os.remove(os.path.join(ffmpeg_extracted_folder, "doc", file)) @@ -101,7 +105,10 @@ def ffmpeg_install(): try: # Try to run the FFmpeg command subprocess.run( - ["ffmpeg", "-version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ["ffmpeg", "-version"], + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, ) except FileNotFoundError as e: # Check if there's ffmpeg.exe in the current directory diff --git a/utils/imagenarator.py b/utils/imagenarator.py index 9356540..151b0e6 100644 --- a/utils/imagenarator.py +++ b/utils/imagenarator.py @@ -1,9 +1,10 @@ +import os import re import textwrap -import os from PIL import Image, ImageDraw, ImageFont from rich.progress import track + from TTS.engine_wrapper import process_text diff --git a/utils/settings.py b/utils/settings.py index 60efedb..8187e9a 100755 --- a/utils/settings.py +++ b/utils/settings.py @@ -1,6 +1,7 @@ import re -from typing import Tuple, Dict from pathlib import Path +from typing import Tuple, Dict + import toml from rich.console import Console diff --git a/utils/subreddit.py b/utils/subreddit.py index f8e60ed..403b6d3 100644 --- a/utils/subreddit.py +++ b/utils/subreddit.py @@ -2,8 +2,8 @@ import json from os.path import exists from utils import settings -from utils.console import print_substep from utils.ai_methods import sort_by_similarity +from utils.console import print_substep def get_subreddit_undone(submissions: list, subreddit, times_checked=0, similarity_scores=None): diff --git a/utils/voice.py b/utils/voice.py index 37933ae..56595fc 100644 --- a/utils/voice.py +++ b/utils/voice.py @@ -4,10 +4,10 @@ import time as pytime from datetime import datetime from time import sleep +from cleantext import clean from requests import Response from utils import settings -from cleantext import clean if sys.version_info[0] >= 3: from datetime import timezone diff --git a/video_creation/background.py b/video_creation/background.py index 8c15b40..2ec9812 100644 --- a/video_creation/background.py +++ b/video_creation/background.py @@ -5,11 +5,12 @@ from pathlib import Path from random import randrange from typing import Any, Tuple, Dict +import yt_dlp from moviepy.editor import VideoFileClip, AudioFileClip from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip + from utils import settings from utils.console import print_step, print_substep -import yt_dlp def load_background_options(): diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 84ca249..5069474 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -1,9 +1,12 @@ import multiprocessing import os import re +import tempfile +import threading +import time from os.path import exists # Needs to be imported specifically from typing import Final -from typing import Tuple, Any, Dict +from typing import Tuple, Dict import ffmpeg import translators @@ -11,15 +14,11 @@ from PIL import Image from rich.console import Console from rich.progress import track +from utils import settings from utils.cleanup import cleanup from utils.console import print_step, print_substep from utils.thumbnail import create_thumbnail from utils.videos import save_data -from utils import settings - -import tempfile -import threading -import time console = Console() diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index fb60bfc..d688caf 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -4,7 +4,6 @@ from pathlib import Path from typing import Dict, Final import translators -from playwright.async_api import async_playwright # pylint: disable=unused-import from playwright.sync_api import ViewportSize, sync_playwright from rich.progress import track @@ -12,7 +11,6 @@ from utils import settings from utils.console import print_step, print_substep from utils.imagenarator import imagemaker from utils.playwright import clear_cookie_by_name - from utils.videos import save_data __all__ = ["download_screenshots_of_reddit_posts"] diff --git a/video_creation/voices.py b/video_creation/voices.py index 4d8495b..8495f8d 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -5,9 +5,9 @@ from rich.console import Console from TTS.GTTS import GTTS from TTS.TikTok import TikTok from TTS.aws_polly import AWSPolly +from TTS.elevenlabs import elevenlabs from TTS.engine_wrapper import TTSEngine from TTS.pyttsx import pyttsx -from TTS.elevenlabs import elevenlabs from TTS.streamlabs_polly import StreamlabsPolly from utils import settings from utils.console import print_table, print_step