# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"2": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"3": {
"class_type": "ByteDanceSeedAudio15VideoToAudio",
"inputs": {
"pitch_rate": 0,
"prompt": "Sarah (woman, mid-thirties, warm and unhurried, close mic, speaking English) says: \"Every voice in this clip was written this morning. By tonight, it will speak thirty-three languages.\"\n\n[She leans in slightly.]\n\nSarah, a little brighter: \"Nothing here was recorded twice. Press play.\"",
"reference_mode": "text only",
"seed": 913502,
"video": [
"2",
0
]
},
"_meta": {
"title": "ByteDance Seed Audio 1.5 Video to Audio"
}
},
"4": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "video/Seed_Audio_1.5_video_dubbing",
"format": "auto",
"format.codec": "auto",
"video": [
"3",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"5": {
"class_type": "SaveAudioAdvanced",
"inputs": {
"audio": [
"3",
1
],
"filename_prefix": "audio/Seed_Audio_1.5_video_dubbing",
"format": "mp3",
"format.quality": "V0"
},
"_meta": {
"title": "Save Audio (Advanced)"
}
},
"6": {
"class_type": "SaveText",
"inputs": {
"filename_prefix": "text/Seed_Audio_1.5_video_dubbing",
"format": "txt",
"text": [
"3",
2
]
},
"_meta": {
"title": "Save Text"
}
}
})
workflow.set_input("2", "file", client.assets.from_url("https://comfy.org/catalog-media/b5ab0395-d7cc-4776-943e-b8c20c8f5caf/ba9aea6c-9664-4ad0-882b-385d158e7933"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("4"):
output.to_file(output.name)