Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,7 +19,6 @@ except KeyError as e:
|
|
19 |
raise ValueError(f"API Key Error: Please set the {e} secret in your Hugging Face Space settings.")
|
20 |
|
21 |
# --- 2. DEFINE API ENDPOINTS AND HEADERS ---
|
22 |
-
# FIX #1: Use the correct V2 endpoint for Runway
|
23 |
RUNWAY_API_URL = "https://api.runwayml.com/v2/tasks"
|
24 |
RUNWAY_HEADERS = {
|
25 |
"Authorization": f"Bearer {RUNWAY_API_KEY}",
|
@@ -66,9 +65,10 @@ def generate_video_from_topic(topic_prompt, progress=gr.Progress(track_tqdm=True
|
|
66 |
audio_path = f"audio_{job_id}.mp3"
|
67 |
intermediate_files.append(audio_path)
|
68 |
|
69 |
-
#
|
|
|
70 |
response = elevenlabs_client.text_to_speech.convert(
|
71 |
-
voice_id="
|
72 |
text=narration,
|
73 |
model_id="eleven_multilingual_v2"
|
74 |
)
|
@@ -77,13 +77,13 @@ def generate_video_from_topic(topic_prompt, progress=gr.Progress(track_tqdm=True
|
|
77 |
for chunk in response:
|
78 |
f.write(chunk)
|
79 |
print(f"Audio file saved: {audio_path}")
|
|
|
80 |
|
81 |
# STEP 4: VISUALS (Runway)
|
82 |
video_clip_paths = []
|
83 |
for i, scene_prompt in enumerate(scene_prompts):
|
84 |
progress(0.4 + (i * 0.12), desc=f"🎬 Generating video scene {i+1}/{len(scene_prompts)}...")
|
85 |
runway_payload = {"text_prompt": scene_prompt}
|
86 |
-
# Use the correct V2 endpoint for starting a job
|
87 |
post_response = requests.post(f"{RUNWAY_API_URL}/text-to-video", headers=RUNWAY_HEADERS, json=runway_payload)
|
88 |
if post_response.status_code != 200:
|
89 |
raise gr.Error(f"Runway API Error (start job): {post_response.status_code} - {post_response.text}")
|
@@ -94,7 +94,6 @@ def generate_video_from_topic(topic_prompt, progress=gr.Progress(track_tqdm=True
|
|
94 |
|
95 |
video_url = None
|
96 |
for _ in range(60):
|
97 |
-
# Use the correct V2 endpoint for polling
|
98 |
get_response = requests.get(f"https://api.runwayml.com/v2/tasks/{task_id}", headers=RUNWAY_HEADERS)
|
99 |
status_details = get_response.json()
|
100 |
status = status_details.get("status")
|
|
|
19 |
raise ValueError(f"API Key Error: Please set the {e} secret in your Hugging Face Space settings.")
|
20 |
|
21 |
# --- 2. DEFINE API ENDPOINTS AND HEADERS ---
|
|
|
22 |
RUNWAY_API_URL = "https://api.runwayml.com/v2/tasks"
|
23 |
RUNWAY_HEADERS = {
|
24 |
"Authorization": f"Bearer {RUNWAY_API_KEY}",
|
|
|
65 |
audio_path = f"audio_{job_id}.mp3"
|
66 |
intermediate_files.append(audio_path)
|
67 |
|
68 |
+
# !!!!!!!!!!! THE FINAL, FINAL FIX !!!!!!!!!!!
|
69 |
+
# We are using the official Voice ID for "Rachel".
|
70 |
response = elevenlabs_client.text_to_speech.convert(
|
71 |
+
voice_id="21m00Tcm4TlvDq8ikA", # Official ID for Rachel
|
72 |
text=narration,
|
73 |
model_id="eleven_multilingual_v2"
|
74 |
)
|
|
|
77 |
for chunk in response:
|
78 |
f.write(chunk)
|
79 |
print(f"Audio file saved: {audio_path}")
|
80 |
+
# !!!!!!!!!!! END OF CORRECTED SECTION !!!!!!!!!!!
|
81 |
|
82 |
# STEP 4: VISUALS (Runway)
|
83 |
video_clip_paths = []
|
84 |
for i, scene_prompt in enumerate(scene_prompts):
|
85 |
progress(0.4 + (i * 0.12), desc=f"🎬 Generating video scene {i+1}/{len(scene_prompts)}...")
|
86 |
runway_payload = {"text_prompt": scene_prompt}
|
|
|
87 |
post_response = requests.post(f"{RUNWAY_API_URL}/text-to-video", headers=RUNWAY_HEADERS, json=runway_payload)
|
88 |
if post_response.status_code != 200:
|
89 |
raise gr.Error(f"Runway API Error (start job): {post_response.status_code} - {post_response.text}")
|
|
|
94 |
|
95 |
video_url = None
|
96 |
for _ in range(60):
|
|
|
97 |
get_response = requests.get(f"https://api.runwayml.com/v2/tasks/{task_id}", headers=RUNWAY_HEADERS)
|
98 |
status_details = get_response.json()
|
99 |
status = status_details.get("status")
|