# 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({
"208": {
"class_type": "ElevenLabsTextToSpeech",
"inputs": {
"apply_text_normalization": "auto",
"language_code": "",
"model": "eleven_multilingual_v2",
"model.similarity_boost": 0.75,
"model.speed": 1,
"model.style": 0,
"model.use_speaker_boost": False,
"output_format": "mp3_44100_192",
"seed": 1,
"stability": 0.5,
"text": "Welcome to the lighthouse at Gannet Point. Step inside, and listen. The wind you hear has been knocking on this door for a hundred and sixty years. On the desk to your left lies the keeper's logbook, its pages stiff with salt, every entry written by lamplight: wind from the west, fog at dawn, oil delivered. Climb the spiral staircase, all one hundred and twelve iron steps, and you will reach the lens room, where brass and glass still catch the afternoon sun. In the winter of 1903, a storm tore the roof from the boathouse and swept the jetty out to sea. For three nights the keeper never slept. And the light never went out. Take your time. The sea is not in a hurry, and neither are we.",
"voice": [
"211",
0
]
},
"_meta": {
"title": "ElevenLabs Text to Speech"
}
},
"211": {
"class_type": "ElevenLabsVoiceSelector",
"inputs": {
"voice": "George (male, british)"
},
"_meta": {
"title": "ElevenLabs Voice Selector"
}
},
"215": {
"class_type": "SaveAudioMP3",
"inputs": {
"audio": [
"208",
0
],
"filename_prefix": "audio/ComfyUI",
"quality": "V0"
},
"_meta": {
"title": "Save Audio (MP3) (DEPRECATED)"
}
}
})
# 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("215"):
output.to_file(output.name)