Repository navigation
Expand file tree
/
Copy pathseed_audio.py
More file actions
38 lines (32 loc) · 1.59 KB
/
Copy pathseed_audio.py
File metadata and controls
38 lines (32 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Seed Audio 1.5 on Muapi. Requires MUAPI_API_KEY and `pip install requests`.
Usage: python seed_audio.py [text-to-audio|stem-separation|video-dubbing|video-translation]"""
import os, sys, time, requests
API = "https://api.muapi.ai/api/v1"
H = {"x-api-key": os.environ["MUAPI_API_KEY"], "Content-Type": "application/json"}
VIDEO = "https://storage.googleapis.com/falserverless/example_outputs/omnihuman_output.mp4"
AUDIO = "https://storage.googleapis.com/falserverless/example_inputs/qwen3-tts/clone_in.mp3"
EXAMPLES = {
"text-to-audio": {
"prompt": 'A calm female narrator says in English: "The rain has stopped." Soft rain ambience, no music.',
"duration": 10,
},
"stem-separation": {"audio_url": AUDIO},
"video-dubbing": {
"video_url": VIDEO,
"prompt": "Re-perform the video's lines in a warm, calm female voice, aligned with the timing of the visuals: "
"'OmniHuman generates video using an image paired with an audio file.'",
},
"video-translation": {"video_url": VIDEO, "target_language": "es-ES"},
}
def run(variant, payload):
job = requests.post(f"{API}/seed-audio-1.5-{variant}", headers=H, json=payload).json()
while True:
r = requests.get(f"{API}/predictions/{job['request_id']}/result", headers=H).json()
if r["status"] == "completed":
return r["outputs"]
if r["status"] == "failed":
raise SystemExit(r)
time.sleep(3)
if __name__ == "__main__":
variant = sys.argv[1] if len(sys.argv) > 1 else "text-to-audio"
print("\n".join(run(variant, EXAMPLES[variant])))