$ 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))21 language = inputs.get("language", "en")22 time_signature = inputs.get("time_signature", "4")23 bpm = int(inputs.get("bpm", 190))24 keyscale = inputs.get("keyscale", "E minor")25 seed = int(inputs.get("seed", -1))2627 if not prompt:28 raise ValueError("Prompt input is required")29 if not lyrics:30 raise ValueError("Lyrics input is required")31 if not (10 <= duration <= 300):32 raise ValueError(f"Duration must be between 10 and 300, got {duration}")33 if not (40 <= bpm <= 300):34 raise ValueError(f"BPM must be between 40 and 300, got {bpm}")3536 os.makedirs(OUTPUT_DIR, exist_ok=True)3738 print(39 f"Requesting music generation: duration={duration}s, bpm={bpm}, "40 f"key={keyscale}, time_sig={time_signature}, language={language}",41 file=sys.stderr,42 )4344 result = Gais.music.create(45 prompt=prompt,46 lyrics=lyrics,47 duration=duration,48 language=language,49 time_signature=time_signature,50 bpm=bpm,51 keyscale=keyscale,52 seed=seed,53 )5455 # Save result56 out_filename = "generated_music.mp3"57 out_path = os.path.join(OUTPUT_DIR, out_filename)58 with open(out_path, "wb") as f:59 f.write(result.content)6061 inference_time = result.metadata.get("inference_time_ms", "unknown")62 print(63 f"Music generated: time={inference_time}ms, duration={duration}s, "64 f"bpm={bpm}, key={keyscale}, time_sig={time_signature}, language={language}",65 file=sys.stderr,66 )6768 # Flat output -- keys match OUTPUT_SCHEMA69 output = {70 "audio": out_filename,71 }72 print(json.dumps(output, indent=2))7374 except Exception as e:75 error_output = {76 "error": str(e),77 "errorType": type(e).__name__,78 "traceback": traceback.format_exc(),79 }80 print(json.dumps(error_output), file=sys.stderr)81 sys.exit(1)828384if __name__ == "__main__":85 main()$ git log --oneline
v1.4.1
HEAD
2026-05-07v1.2.02026-03-29
v1.1.02026-03-20