micziz 2 years ago
commit dbdd13c24b

@ -35,9 +35,9 @@ class AWSPolly:
if random_voice: if random_voice:
voice = self.randomvoice() voice = self.randomvoice()
else: else:
if not os.getenv("VOICE"): if not os.getenv("AWS_VOICE"):
return ValueError( return ValueError(
f"Please set the environment variable VOICE to a valid voice. options are: {voices}" f"Please set the environment variable AWS_VOICE to a valid voice. options are: {voices}"
) )
voice = str(os.getenv("AWS_VOICE")).capitalize() voice = str(os.getenv("AWS_VOICE")).capitalize()
try: try:

@ -72,7 +72,7 @@ class TTSEngine:
print_substep("Saved Text to MP3 files successfully.", style="bold green") print_substep("Saved Text to MP3 files successfully.", style="bold green")
return self.length, idx return self.length, idx
def split_post(self, text: str, idx: int) -> str: def split_post(self, text: str, idx: int):
split_files = [] split_files = []
split_text = [ split_text = [
x.group().strip() x.group().strip()
@ -88,9 +88,15 @@ class TTSEngine:
f"{self.path}/{idx}.mp3", fps=44100, verbose=False, logger=None f"{self.path}/{idx}.mp3", fps=44100, verbose=False, logger=None
) )
for i in range(0, idy + 1): for i in split_files:
name = i.filename
i.close()
Path(name).unlink()
# for i in range(0, idy + 1):
# print(f"Cleaning up {self.path}/{idx}-{i}.part.mp3") # print(f"Cleaning up {self.path}/{idx}-{i}.part.mp3")
Path(f"{self.path}/{idx}-{i}.part.mp3").unlink()
# Path(f"{self.path}/{idx}-{i}.part.mp3").unlink()
def call_tts(self, filename: str, text: str): def call_tts(self, filename: str, text: str):
self.tts_module.run(text=process_text(text), filepath=f"{self.path}/{filename}.mp3") self.tts_module.run(text=process_text(text), filepath=f"{self.path}/{filename}.mp3")
@ -100,6 +106,7 @@ class TTSEngine:
# self.length += sox.file_info.duration(f"{self.path}/{filename}.mp3") # self.length += sox.file_info.duration(f"{self.path}/{filename}.mp3")
clip = AudioFileClip(f"{self.path}/{filename}.mp3") clip = AudioFileClip(f"{self.path}/{filename}.mp3")
self.length += clip.duration self.length += clip.duration
clip.close()
def process_text(text: str): def process_text(text: str):
lang = getenv("POSTLANG", "") lang = getenv("POSTLANG", "")

@ -35,9 +35,9 @@ class StreamlabsPolly:
if random_voice: if random_voice:
voice = self.randomvoice() voice = self.randomvoice()
else: else:
if not os.getenv("VOICE"): if not os.getenv("STREAMLABS_VOICE"):
return ValueError( return ValueError(
f"Please set the environment variable VOICE to a valid voice. options are: {voices}" f"Please set the environment variable STREAMLABS_VOICE to a valid voice. options are: {voices}"
) )
voice = str(os.getenv("STREAMLABS_VOICE")).capitalize() voice = str(os.getenv("STREAMLABS_VOICE")).capitalize()
body = {"voice": voice, "text": text, "service": "polly"} body = {"voice": voice, "text": text, "service": "polly"}

@ -2,6 +2,7 @@ import random
from os import listdir, environ from os import listdir, environ
from pathlib import Path from pathlib import Path
from random import randrange from random import randrange
from typing import Tuple
from moviepy.editor import VideoFileClip from moviepy.editor import VideoFileClip
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
@ -10,7 +11,7 @@ from pytube import YouTube
from utils.console import print_step, print_substep from utils.console import print_step, print_substep
def get_start_and_end_times(video_length: int, length_of_clip: int) -> tuple[int, int]: def get_start_and_end_times(video_length: int, length_of_clip: int) -> Tuple[int, int]:
"""Generates a random interval of time to be used as the background of the video. """Generates a random interval of time to be used as the background of the video.
Args: Args:

Loading…
Cancel
Save