#!/bin/bash
# 1. Generate a reference audio from Vivian
echo "[1] Generating reference audio from Vivian..."
curl -s -o /tmp/vivian_ref.wav \
  -H "Content-Type: application/json" \
  -d '{"input":"Dies ist ein Test der Sprachsynthese. Meine Stimme sollte geklont werden koennen.","voice":"Vivian","language":"german"}' \
  http://localhost:8072/v1/audio/speech
echo "Generated /tmp/vivian_ref.wav: $(ls -la /tmp/vivian_ref.wav 2>&1)"

# 2. Train a custom voice from that audio  
echo ""
echo "[2] Training custom voice 'meine_stimme' from reference audio..."
curl -v -X POST http://localhost:8072/v1/voices/train \
  -F "audio=@/tmp/vivian_ref.wav" \
  -F "name=meine_stimme" \
  -F "text=Dies ist ein Test der Sprachsynthese." \
  -F "description=Vivian clone test" \
  -F "language=german" \
  2>&1

# 3. List voices  
echo ""
echo "[3] Listing all voices..."
curl -s http://localhost:8072/v1/voices 2>&1

# 4. Generate speech with the cloned voice
echo ""
echo "[4] Generating speech with cloned voice..."
curl -s -o /tmp/clone_test.wav \
  -H "Content-Type: application/json" \
  -d '{"input":"Hallo, ich bin eine geklonte Stimme. Das ist ziemlich cool.","voice":"meine_stimme","language":"german"}' \
  http://localhost:8072/v1/audio/speech
echo "Generated /tmp/clone_test.wav: $(ls -la /tmp/clone_test.wav 2>&1)"

# 5. Voice details
echo ""
echo "[5] Voice details..."
curl -s http://localhost:8072/v1/voices/meine_stimme 2>&1
