-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (27 loc) · 1.27 KB
/
app.py
File metadata and controls
38 lines (27 loc) · 1.27 KB
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
from flask import Flask, render_template, request
from extract import extract_keywords
from text_to_speech import tts
from pexels_video_search import search_pexels_videos, filter_landscape_videos
from combine_videos import download_and_save_videos, combine_videos_and_add_subtitles
app = Flask(__name__)
@app.route("/", methods=["GET", "POST"])
def index():
if request.method == "POST":
text = request.form["text"]
voice = request.form["voice"]
tts(text, voice)
# Extract keywords from the text using DeepAI API
keywords = extract_keywords(text)
print(keywords[:5])
# Search for videos using the extracted keywords
videos = search_pexels_videos(keywords)
landscape_videos = filter_landscape_videos(videos)
if not landscape_videos:
return "No landscape videos found for the given keywords."
# Download and save videos as VideoFileClip objects
video_clips = download_and_save_videos(landscape_videos, save_dir="video_clips")
# Combine videos and add subtitles
combine_videos_and_add_subtitles(video_clips, text)
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)