# 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({
"218": {
"class_type": "ElevenLabsSpeechToText",
"inputs": {
"audio": [
"219",
0
],
"language_code": "",
"model": "scribe_v2",
"model.diarization_threshold": 0.22,
"model.diarize": False,
"model.tag_audio_events": False,
"model.temperature": 0,
"model.timestamps_granularity": "word",
"num_speakers": 0,
"seed": 519926995
},
"_meta": {
"title": "ElevenLabs Speech to Text"
}
},
"219": {
"class_type": "LoadAudio",
"inputs": {
"audio": "voice_demo.mp3"
},
"_meta": {
"title": "Load Audio"
}
},
"221": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"218",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"222": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"218",
2
]
},
"_meta": {
"title": "words_json"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)