This repository was archived by the owner on Apr 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrun.py
48 lines (41 loc) · 1.52 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from os import environ as env
from dotenv import load_dotenv
from scraper import Scraper
from tts import TTS
from videoGen import VideoGenerator
from forcedAligner import ForcedAligner
import os
from gpt import GPT
load_dotenv()
scraper = Scraper(env)
post = scraper.getHotPosts()
postTitle = post[0]
postTitleAndText = post[1]
print("Scraped post: "+postTitleAndText)
languages = env['LANGUAGES'].split(',')
languages = [lang.lower() for lang in languages]
gpt = GPT(env)
gender = gpt.getGender(postTitleAndText)
for language in languages:
editedPost = gpt.expandAcronymsAndAbbreviations(postTitleAndText, language)
tts = TTS(env)
audioFile = tts.createAudio(editedPost, gender, language)
print("Created audio file: " + audioFile)
if env['SUBTITLES'].upper() == 'TRUE' and language == 'english':
subtitlesPath = 'tts-audio-files/subtitles.srt'
forcedAligner = ForcedAligner(
env['GENTLE_URL'], env)
subtitleText = gpt.getSubtitles(editedPost)
forcedAligner.align(audioFile, subtitleText, subtitlesPath)
else:
subtitlesPath = None
videoGen = VideoGenerator(env)
directory = 'background-videos'
outputPath = os.path.join('output', language+'.mp4')
bgVideoFileName = env['BG_VIDEO_FILENAME']
videoFile = videoGen.generateVideo(
bgVideoFileName, audioFile, outputPath, directory, subtitlesPath)
if (videoFile != False):
print("Created output video file at: " + videoFile)
else:
print("Failed to create output video file")