#!/bin/sh
# PUBLIC DOMAIN - NO LICENSE, NO WARRANTY
# Copyright 2025 TimeHexOn & foxhop & russell@unturf
# https://www.permacomputer.com

# Use first TTS endpoint
if [ ! -f /tmp/tts_endpoint.txt ]; then
  echo "ERROR: No TTS endpoints discovered"
  exit 1
fi

endpoint=$(cat /tmp/tts_endpoint.txt)

echo "Using TTS endpoint: $endpoint"

curl -s "${endpoint}/audio/speech" \
  -H 'Content-Type: application/json' \
  -d '{"model":"tts-1","voice":"alloy","input":"Hello from COBOL! This is a text to speech example."}' \
  -o /app/output.mp3 2>/dev/null
