Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ 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 |
-
#
|
23 |
RUNWAY_API_URL = "https://api.runwayml.com/v2/tasks"
|
24 |
RUNWAY_HEADERS = {
|
25 |
"Authorization": f"Bearer {RUNWAY_API_KEY}",
|
@@ -66,11 +66,13 @@ 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 |
response = elevenlabs_client.text_to_speech.convert(
|
70 |
voice_id="oWAxZDx7w5z9imAaTrzz", # Official ID for Adam
|
71 |
text=narration,
|
72 |
model_id="eleven_multilingual_v2"
|
73 |
)
|
|
|
74 |
with open(audio_path, "wb") as f:
|
75 |
for chunk in response:
|
76 |
f.write(chunk)
|
@@ -81,6 +83,7 @@ def generate_video_from_topic(topic_prompt, progress=gr.Progress(track_tqdm=True
|
|
81 |
for i, scene_prompt in enumerate(scene_prompts):
|
82 |
progress(0.4 + (i * 0.12), desc=f"🎬 Generating video scene {i+1}/{len(scene_prompts)}...")
|
83 |
runway_payload = {"text_prompt": scene_prompt}
|
|
|
84 |
post_response = requests.post(f"{RUNWAY_API_URL}/text-to-video", headers=RUNWAY_HEADERS, json=runway_payload)
|
85 |
if post_response.status_code != 200:
|
86 |
raise gr.Error(f"Runway API Error (start job): {post_response.status_code} - {post_response.text}")
|
@@ -91,7 +94,7 @@ def generate_video_from_topic(topic_prompt, progress=gr.Progress(track_tqdm=True
|
|
91 |
|
92 |
video_url = None
|
93 |
for _ in range(60):
|
94 |
-
#
|
95 |
get_response = requests.get(f"https://api.runwayml.com/v2/tasks/{task_id}", headers=RUNWAY_HEADERS)
|
96 |
status_details = get_response.json()
|
97 |
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 |
+
# 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 |
audio_path = f"audio_{job_id}.mp3"
|
67 |
intermediate_files.append(audio_path)
|
68 |
|
69 |
+
# FIX #2: Use the official Voice ID for "Adam"
|
70 |
response = elevenlabs_client.text_to_speech.convert(
|
71 |
voice_id="oWAxZDx7w5z9imAaTrzz", # Official ID for Adam
|
72 |
text=narration,
|
73 |
model_id="eleven_multilingual_v2"
|
74 |
)
|
75 |
+
|
76 |
with open(audio_path, "wb") as f:
|
77 |
for chunk in response:
|
78 |
f.write(chunk)
|
|
|
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 |
|
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")
|