PlotweaverModel commited on
Commit
e6b274c
·
verified ·
1 Parent(s): 34ba0b7

Upload 2 files

Browse files
Files changed (1) hide show
  1. app.py +3 -48
app.py CHANGED
@@ -60,14 +60,6 @@ TTS_SYNTHESIS_URL = f"{DASHSCOPE_API_URL}/services/aigc/multimodal-generation/ge
60
 
61
  # HappyHorse API endpoints per provider
62
  HAPPYHORSE_PROVIDERS = {
63
- "fal.ai": {
64
- "t2v": "https://queue.fal.run/fal-ai/alibaba/happy-horse/text-to-video",
65
- "i2v": "https://queue.fal.run/fal-ai/alibaba/happy-horse/image-to-video",
66
- "status_base": "https://queue.fal.run/fal-ai/alibaba/happy-horse",
67
- "key_env": "FAL_API_KEY",
68
- "auth_header": "Authorization",
69
- "auth_prefix": "Key ",
70
- },
71
  "happyhorse.app": {
72
  "generate": "https://happyhorse.app/api/generate",
73
  "status": "https://happyhorse.app/api/status",
@@ -425,41 +417,6 @@ def narrate_scene_cloned(client, text, voice_id, language, lang_config, translat
425
  # ==========================================
426
  # HAPPYHORSE VIDEO GENERATION
427
  # ==========================================
428
- def generate_video_fal(prompt, api_key, duration=5, aspect="16:9", image_url=None):
429
- """Generate video via fal.ai."""
430
- headers = {"Authorization": f"Key {api_key}", "Content-Type": "application/json"}
431
-
432
- if image_url:
433
- payload = {"image_url": image_url, "prompt": prompt, "duration": duration, "aspect_ratio": aspect}
434
- url = HAPPYHORSE_PROVIDERS["fal.ai"]["i2v"]
435
- else:
436
- payload = {"prompt": prompt, "duration": duration, "aspect_ratio": aspect}
437
- url = HAPPYHORSE_PROVIDERS["fal.ai"]["t2v"]
438
-
439
- resp = http_requests.post(url, json=payload, headers=headers, timeout=30)
440
- if resp.status_code not in (200, 201):
441
- raise RuntimeError(f"fal.ai submit failed: {resp.status_code} {resp.text[:200]}")
442
-
443
- data = resp.json()
444
- # fal uses queue -- check for request_id
445
- request_id = data.get("request_id")
446
- if request_id:
447
- status_url = f"{url}/requests/{request_id}/status"
448
- result_url = f"{url}/requests/{request_id}"
449
- for _ in range(120):
450
- time.sleep(10)
451
- s = http_requests.get(status_url, headers=headers, timeout=30).json()
452
- if s.get("status") == "COMPLETED":
453
- r = http_requests.get(result_url, headers=headers, timeout=30).json()
454
- video_url = r.get("video", {}).get("url")
455
- return video_url
456
- elif s.get("status") == "FAILED":
457
- raise RuntimeError(f"fal.ai generation failed")
458
- raise RuntimeError("fal.ai timeout")
459
- else:
460
- return data.get("video", {}).get("url")
461
-
462
-
463
  def generate_video_happyhorse_app(prompt, api_key, duration=5, aspect="16:9", image_url=None):
464
  """Generate video via happyhorse.app."""
465
  headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
@@ -537,9 +494,7 @@ def generate_video_dashscope(prompt, api_key, duration=5, aspect="16:9", image_u
537
 
538
  def generate_video(prompt, provider, api_key, duration=5, aspect="16:9", image_url=None):
539
  """Route to the correct provider."""
540
- if provider == "fal.ai":
541
- return generate_video_fal(prompt, api_key, duration, aspect, image_url)
542
- elif provider == "happyhorse.app":
543
  return generate_video_happyhorse_app(prompt, api_key, duration, aspect, image_url)
544
  elif provider == "DashScope (Bailian)":
545
  return generate_video_dashscope(prompt, api_key, duration, aspect, image_url)
@@ -956,8 +911,8 @@ with gr.Blocks(
956
  "**Pipeline:** Text > Split into scenes > Qwen generates video prompts > "
957
  "HappyHorse generates video per scene > Qwen narrates audio per scene > "
958
  "FFmpeg composites video+audio > Concatenates all scenes into final MP4\n\n"
959
- "**API Keys needed:** DASHSCOPE_API_KEY (audio) + one of: FAL_API_KEY, HAPPYHORSE_API_KEY, "
960
- "or DASHSCOPE_API_KEY also for video (DashScope provider)\n\n"
961
  "Built with Gradio | Narration by Qwen | Video by HappyHorse 1.0"
962
  )
963
 
 
60
 
61
  # HappyHorse API endpoints per provider
62
  HAPPYHORSE_PROVIDERS = {
 
 
 
 
 
 
 
 
63
  "happyhorse.app": {
64
  "generate": "https://happyhorse.app/api/generate",
65
  "status": "https://happyhorse.app/api/status",
 
417
  # ==========================================
418
  # HAPPYHORSE VIDEO GENERATION
419
  # ==========================================
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  def generate_video_happyhorse_app(prompt, api_key, duration=5, aspect="16:9", image_url=None):
421
  """Generate video via happyhorse.app."""
422
  headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
 
494
 
495
  def generate_video(prompt, provider, api_key, duration=5, aspect="16:9", image_url=None):
496
  """Route to the correct provider."""
497
+ if provider == "happyhorse.app":
 
 
498
  return generate_video_happyhorse_app(prompt, api_key, duration, aspect, image_url)
499
  elif provider == "DashScope (Bailian)":
500
  return generate_video_dashscope(prompt, api_key, duration, aspect, image_url)
 
911
  "**Pipeline:** Text > Split into scenes > Qwen generates video prompts > "
912
  "HappyHorse generates video per scene > Qwen narrates audio per scene > "
913
  "FFmpeg composites video+audio > Concatenates all scenes into final MP4\n\n"
914
+ "**API Keys needed:** DASHSCOPE_API_KEY (audio) + HAPPYHORSE_API_KEY (if using happyhorse.app) "
915
+ "or just DASHSCOPE_API_KEY for both audio and video (DashScope provider)\n\n"
916
  "Built with Gradio | Narration by Qwen | Video by HappyHorse 1.0"
917
  )
918