$ cat node-template.py
M
Music Creation
// Generates a music track from a style description and lyrics. Supports configurable BPM, musical key, time signature, duration, and multiple languages.
Process
Audio
template.py
1import os2import sys3import json4import traceback56from gais import Gais78OUTPUT_DIR = "/data/output"91011def main():12 try:13 input_json = sys.stdin.read()14 execution_input = json.loads(input_json)15 inputs = execution_input.get("inputs", {})16 service_defaults = execution_input.get("service_defaults", {})1718 prompt = inputs.get("prompt", "")19 lyrics = inputs.get("lyrics", "")20 duration = int(inputs.get("duration", 90) or 90)21 language = inputs.get("language", "en")22 time_signature = inputs.get("time_signature", "4")23 bpm = int(inputs.get("bpm", 190) or 190)24 keyscale = inputs.get("keyscale", "E minor")25 seed_in = inputs.get("seed", -1)26 seed = int(seed_in) if seed_in not in (None, "") else -12728 if not prompt:29 raise ValueError("Prompt input is required")30 if not lyrics:31 raise ValueError("Lyrics input is required")32 if not (10 <= duration <= 300):33 raise ValueError(f"Duration must be between 10 and 300, got {duration}")34 if not (40 <= bpm <= 300):35 raise ValueError(f"BPM must be between 40 and 300, got {bpm}")3637 os.makedirs(OUTPUT_DIR, exist_ok=True)3839 print(40 f"Requesting music generation: duration={duration}s, bpm={bpm}, "41 f"key={keyscale}, time_sig={time_signature}, language={language}",42 file=sys.stderr,43 )4445 result = Gais.music.create(46 prompt=prompt,47 lyrics=lyrics,48 duration=duration,49 language=language,50 time_signature=time_signature,51 bpm=bpm,52 keyscale=keyscale,53 seed=seed,54 )5556 # Save result57 out_filename = "generated_music.mp3"58 out_path = os.path.join(OUTPUT_DIR, out_filename)59 with open(out_path, "wb") as f:60 f.write(result.content)6162 inference_time = result.metadata.get("inference_time_ms", "unknown")63 print(64 f"Music generated: time={inference_time}ms, duration={duration}s, "65 f"bpm={bpm}, key={keyscale}, time_sig={time_signature}, language={language}",66 file=sys.stderr,67 )6869 # Flat output -- keys match OUTPUT_SCHEMA70 output = {71 "audio": out_filename,72 }73 print(json.dumps(output, indent=2))7475 except Exception as e:76 error_output = {77 "error": str(e),78 "errorType": type(e).__name__,79 "traceback": traceback.format_exc(),80 }81 print(json.dumps(error_output), file=sys.stderr)82 sys.exit(1)838485if __name__ == "__main__":86 main()$ git log --oneline
v1.4.2
HEAD
2026-08-18v1.4.12026-05-07
v1.2.02026-03-29
v1.1.02026-03-20