Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,61 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import asyncio
|
| 3 |
-
from utility.script_generator import generate_script
|
| 4 |
-
from utility.audio_generator import generate_audio
|
| 5 |
-
from utility.timed_captions_generator import generate_timed_captions
|
| 6 |
-
from utility.background_video_generator import generate_video_url
|
| 7 |
-
from utility.render_engine import get_output_media
|
| 8 |
-
from utility.video_search_query_generator import getVideoSearchQueriesTimed, merge_empty_intervals
|
| 9 |
-
|
| 10 |
-
SAMPLE_FILE_NAME = "audio_tts.wav"
|
| 11 |
-
VIDEO_SERVER = "pexel"
|
| 12 |
-
|
| 13 |
-
async def process_topic(topic):
|
| 14 |
-
# Generate script from topic
|
| 15 |
-
response = generate_script(topic)
|
| 16 |
-
print("Script:", response)
|
| 17 |
-
|
| 18 |
-
# Generate audio from script
|
| 19 |
-
await generate_audio(response, SAMPLE_FILE_NAME)
|
| 20 |
-
|
| 21 |
-
# Generate timed captions from audio
|
| 22 |
-
timed_captions = generate_timed_captions(SAMPLE_FILE_NAME)
|
| 23 |
-
print("Timed Captions:", timed_captions)
|
| 24 |
-
|
| 25 |
-
# Generate video search queries based on the script and captions
|
| 26 |
-
search_terms = getVideoSearchQueriesTimed(response, timed_captions)
|
| 27 |
-
print("Search Terms:", search_terms)
|
| 28 |
-
|
| 29 |
-
# Get background video URLs
|
| 30 |
-
background_video_urls = None
|
| 31 |
-
if search_terms is not None:
|
| 32 |
-
background_video_urls = generate_video_url(search_terms, VIDEO_SERVER)
|
| 33 |
-
print("Background Video URLs:", background_video_urls)
|
| 34 |
-
else:
|
| 35 |
-
print("No background video")
|
| 36 |
-
|
| 37 |
-
# Merge empty intervals
|
| 38 |
-
background_video_urls = merge_empty_intervals(background_video_urls)
|
| 39 |
-
|
| 40 |
-
# Generate the final video
|
| 41 |
-
if background_video_urls is not None:
|
| 42 |
-
video = get_output_media(SAMPLE_FILE_NAME, timed_captions, background_video_urls, VIDEO_SERVER)
|
| 43 |
-
print("Generated Video:", video)
|
| 44 |
-
return video
|
| 45 |
-
else:
|
| 46 |
-
print("No video generated")
|
| 47 |
-
return "No video generated"
|
| 48 |
-
|
| 49 |
-
def generate_video(topic):
|
| 50 |
-
video_url = asyncio.run(process_topic(topic))
|
| 51 |
-
return video_url
|
| 52 |
-
|
| 53 |
-
with gr.Blocks() as demo:
|
| 54 |
-
gr.Markdown("# Video Generator from Topic")
|
| 55 |
-
topic_input = gr.Textbox(label="Enter the Topic", placeholder="Type a topic for the video...")
|
| 56 |
-
output_video = gr.Video(label="Generated Video")
|
| 57 |
-
generate_btn = gr.Button("Generate Video")
|
| 58 |
-
|
| 59 |
-
generate_btn.click(fn=generate_video, inputs=topic_input, outputs=output_video)
|
| 60 |
-
|
| 61 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|