Spaces:
Runtime error
Runtime error
Commit ·
eceb1dc
1
Parent(s): 101b77a
Update app.py
Browse files
app.py
CHANGED
|
@@ -136,7 +136,7 @@ def generate_image(visual_prompt, API_KEY, ENDPOINT):
|
|
| 136 |
# Handle the Response
|
| 137 |
if response.status_code == 200:
|
| 138 |
image_url = response.json()['data'][0]['url']
|
| 139 |
-
print(f"Image
|
| 140 |
return image_url
|
| 141 |
else:
|
| 142 |
error_message = f"Error in image generation: {response.status_code}, {response.text}"
|
|
@@ -191,6 +191,8 @@ def generate_video(slo):
|
|
| 191 |
print("Generating images...")
|
| 192 |
pattern = r'^VISUAL PROMPT:(.*)$'
|
| 193 |
visual_prompts = re.findall(pattern, script_text, re.MULTILINE)
|
|
|
|
|
|
|
| 194 |
generated_image_urls = []
|
| 195 |
API_KEY = api_key
|
| 196 |
ENDPOINT = 'https://api.openai.com/v1/images/generations'
|
|
@@ -202,6 +204,8 @@ def generate_video(slo):
|
|
| 202 |
# Step 3: Generate Videos from Images
|
| 203 |
print("Generating videos from images...")
|
| 204 |
generated_video_urls = generate_videos_from_images(generated_image_urls)
|
|
|
|
|
|
|
| 205 |
|
| 206 |
# Step 4: Voiceover Generation and Upload to AWS S3
|
| 207 |
print("Generating voiceovers and uploading to AWS S3...")
|
|
@@ -215,6 +219,7 @@ def generate_video(slo):
|
|
| 215 |
|
| 216 |
# Step 5: Video Compilation with Creatomate
|
| 217 |
print("Compiling video with Creatomate...")
|
|
|
|
| 218 |
modifications = {f'Visual prompt-{i+1}': url for i, url in enumerate(generated_video_urls)}
|
| 219 |
for index, audio_url in enumerate(s3_voiceover_urls):
|
| 220 |
modifications[f"vo_line_{index+1}"] = audio_url
|
|
|
|
| 136 |
# Handle the Response
|
| 137 |
if response.status_code == 200:
|
| 138 |
image_url = response.json()['data'][0]['url']
|
| 139 |
+
print(f"Image URL {len(generated_image_urls)+1}: {image_url}")
|
| 140 |
return image_url
|
| 141 |
else:
|
| 142 |
error_message = f"Error in image generation: {response.status_code}, {response.text}"
|
|
|
|
| 191 |
print("Generating images...")
|
| 192 |
pattern = r'^VISUAL PROMPT:(.*)$'
|
| 193 |
visual_prompts = re.findall(pattern, script_text, re.MULTILINE)
|
| 194 |
+
for idx, prompt in enumerate(visual_prompts):
|
| 195 |
+
print(f"Visual Prompt {idx+1}: {prompt.strip()}")
|
| 196 |
generated_image_urls = []
|
| 197 |
API_KEY = api_key
|
| 198 |
ENDPOINT = 'https://api.openai.com/v1/images/generations'
|
|
|
|
| 204 |
# Step 3: Generate Videos from Images
|
| 205 |
print("Generating videos from images...")
|
| 206 |
generated_video_urls = generate_videos_from_images(generated_image_urls)
|
| 207 |
+
for idx, url in enumerate(generated_video_urls):
|
| 208 |
+
print(f"Generated Video URL {idx+1}: {url}")
|
| 209 |
|
| 210 |
# Step 4: Voiceover Generation and Upload to AWS S3
|
| 211 |
print("Generating voiceovers and uploading to AWS S3...")
|
|
|
|
| 219 |
|
| 220 |
# Step 5: Video Compilation with Creatomate
|
| 221 |
print("Compiling video with Creatomate...")
|
| 222 |
+
print(f"Payload for video compilation: {payload}")
|
| 223 |
modifications = {f'Visual prompt-{i+1}': url for i, url in enumerate(generated_video_urls)}
|
| 224 |
for index, audio_url in enumerate(s3_voiceover_urls):
|
| 225 |
modifications[f"vo_line_{index+1}"] = audio_url
|