Spaces:
Running
Running
codewithdark
commited on
Upload 2 files
Browse files- app.py +61 -0
- requirements.txt +54 -0
app.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
import asyncio
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
from utility.logging import log_response
|
6 |
+
from utility.script_generator import generate_script
|
7 |
+
from utility.audio_generator import generate_audio
|
8 |
+
from utility.timed_captions_generator import generate_timed_captions
|
9 |
+
from utility.image_generator import generate_image_prompts, generate_images
|
10 |
+
from utility.render_engine import get_output_media
|
11 |
+
|
12 |
+
# Load environment variables
|
13 |
+
load_dotenv()
|
14 |
+
|
15 |
+
# Define async function to run in Streamlit
|
16 |
+
async def generate_content(topic):
|
17 |
+
st.write("Generating script for topic:", topic)
|
18 |
+
script = generate_script(topic)
|
19 |
+
st.write("Generated Script:")
|
20 |
+
st.write(script)
|
21 |
+
|
22 |
+
audio_file = "output_audio.mp3"
|
23 |
+
|
24 |
+
st.write("Generating audio...")
|
25 |
+
await generate_audio(script, audio_file)
|
26 |
+
st.write(f"Audio generated and saved to {audio_file}")
|
27 |
+
|
28 |
+
st.write("Generating timed captions...")
|
29 |
+
captions_timed = generate_timed_captions(audio_file)
|
30 |
+
st.write("Timed Captions:")
|
31 |
+
st.write(captions_timed)
|
32 |
+
|
33 |
+
st.write("Generating images from prompts...")
|
34 |
+
prompts = generate_image_prompts(script)
|
35 |
+
image_files = generate_images(prompts)
|
36 |
+
st.write("Generated Images:")
|
37 |
+
st.image(image_files, caption=prompts, use_column_width=True)
|
38 |
+
|
39 |
+
st.write("Rendering output media...")
|
40 |
+
output_file = get_output_media(audio_file, captions_timed, image_files)
|
41 |
+
st.write(f"Output media generated: {output_file}")
|
42 |
+
|
43 |
+
# Provide a link to download the output video file
|
44 |
+
with open(output_file, 'rb') as f:
|
45 |
+
st.download_button(label="Download Output Video", data=f, file_name=output_file, mime='video/mp4')
|
46 |
+
|
47 |
+
# Define the Streamlit app layout
|
48 |
+
def main():
|
49 |
+
st.title("AI Media Content Generator")
|
50 |
+
st.write("This app generates audio, images, and captions based on a topic using AI.")
|
51 |
+
|
52 |
+
# Input field for the topic
|
53 |
+
topic = st.text_input("Enter a topic:", "Future of AI")
|
54 |
+
|
55 |
+
# Run the generation when button is clicked
|
56 |
+
if st.button("Generate Content"):
|
57 |
+
# Run the asynchronous function using asyncio and Streamlit's `st.experimental_singleton` to handle async calls
|
58 |
+
asyncio.run(generate_content(topic))
|
59 |
+
|
60 |
+
if __name__ == "__main__":
|
61 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiohttp==3.9.5
|
2 |
+
aiosignal==1.3.1
|
3 |
+
annotated-types==0.7.0
|
4 |
+
anyio==4.4.0
|
5 |
+
attrs==23.2.0
|
6 |
+
certifi==2024.6.2
|
7 |
+
charset-normalizer==3.3.2
|
8 |
+
Cython==3.0.10
|
9 |
+
decorator==4.4.2
|
10 |
+
distro==1.9.0
|
11 |
+
dtw-python==1.5.1
|
12 |
+
edge-tts==6.1.12
|
13 |
+
filelock==3.14.0
|
14 |
+
frozenlist==1.4.1
|
15 |
+
fsspec==2024.6.0
|
16 |
+
h11==0.14.0
|
17 |
+
httpcore==1.0.5
|
18 |
+
httpx==0.27.0
|
19 |
+
edge_tts==6.1.12
|
20 |
+
idna==3.7
|
21 |
+
imageio==2.34.1
|
22 |
+
imageio-ffmpeg==0.5.1
|
23 |
+
Jinja2==3.1.4
|
24 |
+
llvmlite==0.42.0
|
25 |
+
MarkupSafe==2.1.5
|
26 |
+
more-itertools==10.2.0
|
27 |
+
moviepy==1.0.3
|
28 |
+
mpmath==1.3.0
|
29 |
+
g4f
|
30 |
+
multidict==6.0.5
|
31 |
+
networkx==3.3
|
32 |
+
numba==0.59.1
|
33 |
+
numpy==1.26.4
|
34 |
+
openai-whisper==20231117
|
35 |
+
pillow==10.3.0
|
36 |
+
proglog==0.1.10
|
37 |
+
pydantic==2.7.3
|
38 |
+
pydantic_core==2.18.4
|
39 |
+
regex==2024.5.15
|
40 |
+
requests==2.32.3
|
41 |
+
scipy==1.13.1
|
42 |
+
sniffio==1.3.1
|
43 |
+
sympy==1.12.1
|
44 |
+
tiktoken==0.7.0
|
45 |
+
torch==2.4.1
|
46 |
+
tqdm==4.66.4
|
47 |
+
transformers==4.44.2
|
48 |
+
diffusers==0.20.1
|
49 |
+
python-dotenv==0.0.5
|
50 |
+
typing_extensions==4.12.1
|
51 |
+
urllib3==2.2.1
|
52 |
+
whisper_timestamped==1.15.4
|
53 |
+
yarl==1.9.4
|
54 |
+
streamlit==1.29.1
|