$ cat node-template.py

T

Text to Speech

// Converts text to speech with support for 23 languages and optional voice cloning. Produces natural, expressive speech from text input.

Process
Audio
template.py
1import os2import sys3import json4import traceback56from gais import Gais78INPUT_DIR = "/data/input"9OUTPUT_DIR = "/data/output"101112def main():13    try:14        input_json = sys.stdin.read()15        execution_input = json.loads(input_json)16        inputs = execution_input.get("inputs", {})1718        prompt = inputs.get("prompt", "")19        voice_reference = inputs.get("voice_reference", "")20        language = inputs.get("language", "Italian")21        seed_in = inputs.get("seed", 0)22        seed = int(seed_in) if seed_in not in (None, "") else 02324        if not prompt:25            raise ValueError("Prompt input is required")2627        os.makedirs(OUTPUT_DIR, exist_ok=True)2829        # Resolve optional voice reference path30        voice_path = None31        if voice_reference:32            voice_path = os.path.join(INPUT_DIR, voice_reference)33            if not os.path.exists(voice_path):34                raise FileNotFoundError(f"Voice reference not found: {voice_path}")3536        print(37            f"Requesting speech generation: language={language}, seed={seed}, "38            f"voice_cloning={bool(voice_reference)}",39            file=sys.stderr,40        )4142        result = Gais.speech.create(43            text=prompt,44            language=language,45            seed=seed,46            voice_reference=voice_path,47        )4849        # Save result50        out_filename = "generated_speech.mp3"51        out_path = os.path.join(OUTPUT_DIR, out_filename)52        with open(out_path, "wb") as f:53            f.write(result.content)5455        inference_time = result.metadata.get("inference_time_ms", "unknown")56        print(57            f"Speech generated: time={inference_time}ms, language={language}, "58            f"seed={seed}, voice_cloning={bool(voice_reference)}",59            file=sys.stderr,60        )6162        # Flat output -- keys match OUTPUT_SCHEMA63        output = {64            "audio": out_filename,65        }66        print(json.dumps(output, indent=2))6768    except Exception as e:69        error_output = {70            "error": str(e),71            "errorType": type(e).__name__,72            "traceback": traceback.format_exc(),73        }74        print(json.dumps(error_output), file=sys.stderr)75        sys.exit(1)767778if __name__ == "__main__":79    main()

$ git log --oneline

v1.6.1
HEAD
2026-08-18
v1.6.02026-05-07
v1.3.02026-03-29
v1.2.02026-03-20