uncloseai-speech/Makefile
Russell Ballestrini 2c6c1ad577 Add XTTS support to Makefile and create CLAUDE.md guide
Makefile improvements:
- Add voices-xtts target to download speaker samples
- Add test-xtts target for testing HD model
- Split voices into voices-piper and voices-xtts
- Update help text with all new targets

speech.py:
- Fix threading import scope issue for XTTS
- Remove redundant 'import threading' inside Piper block

docs/CLAUDE.md:
- Complete guide for Claude Code contributors
- Makefile-first development philosophy
- Never create dirs manually, always use Makefile
- Documentation requirements and testing philosophy
- Common mistakes to avoid
- Raccoon mission values and principles

This ensures consistent, repeatable deployments and makes it easy
to add new TTS engines following the same pattern.

🦝 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 09:52:13 -05:00

112 lines
5.3 KiB
Makefile

# Raccoon Mission: UncloseAI Speech Development Makefile
# Deploy to remote server with ease
# Configuration is loaded from vars.sh (copy vars.sh.example to vars.sh)
# Load configuration from vars.sh if it exists
ifneq (,$(wildcard vars.sh))
include vars.sh
export
endif
# Fallback defaults if vars.sh is not found
REMOTE_HOST ?= localhost
REMOTE_USER ?= $(USER)
REMOTE_PATH ?= ~/uncloseai-speech
CONTAINER_NAME ?= uncloseai-speech-server-1
.PHONY: help deploy sync restart logs test clean stop start voices voices-piper voices-xtts
help:
@echo "🦝 Raccoon TTS Mission - Development Commands"
@echo ""
@echo "Deployment:"
@echo " make deploy - Full deploy: sync files, restart container"
@echo " make sync - Sync local files to remote server"
@echo " make restart - Restart the Docker container"
@echo ""
@echo "Development:"
@echo " make logs - Tail container logs"
@echo " make test - Test TTS endpoint (Piper)"
@echo " make test-xtts - Test XTTS HD endpoint"
@echo " make voices - Download all voices (Piper + XTTS)"
@echo " make voices-piper - Download Piper voices only"
@echo " make voices-xtts - Download XTTS voices and samples"
@echo ""
@echo "Container:"
@echo " make start - Start Docker container"
@echo " make stop - Stop Docker container"
@echo " make clean - Stop and remove container"
sync:
@echo "📦 Syncing files to $(REMOTE_HOST)..."
rsync -avz --exclude '.git' --exclude '__pycache__' --exclude '*.pyc' \
--exclude 'voices/*' --exclude 'config/voice_to_speaker.yaml' \
./ $(REMOTE_USER)@$(REMOTE_HOST):$(REMOTE_PATH)/
@echo "📝 Ensuring speech.env exists..."
ssh $(REMOTE_USER)@$(REMOTE_HOST) "cd $(REMOTE_PATH) && [ -f speech.env ] || cp sample.env speech.env"
deploy: sync restart
@echo "✅ Deployment complete!"
restart:
@echo "🔄 Rebuilding and restarting container on $(REMOTE_HOST)..."
ssh $(REMOTE_USER)@$(REMOTE_HOST) "cd $(REMOTE_PATH) && docker compose up -d --build"
stop:
@echo "🛑 Stopping container on $(REMOTE_HOST)..."
ssh $(REMOTE_USER)@$(REMOTE_HOST) "cd $(REMOTE_PATH) && docker compose down"
start:
@echo "▶️ Starting container on $(REMOTE_HOST)..."
ssh $(REMOTE_USER)@$(REMOTE_HOST) "cd $(REMOTE_PATH) && docker compose up -d"
clean: stop
@echo "🧹 Removing container..."
ssh $(REMOTE_USER)@$(REMOTE_HOST) "cd $(REMOTE_PATH) && docker compose down -v"
logs:
@echo "📋 Tailing logs from $(REMOTE_HOST)..."
ssh $(REMOTE_USER)@$(REMOTE_HOST) "docker logs -f $(CONTAINER_NAME)"
test:
@echo "🧪 Testing TTS endpoint..."
curl -X POST http://$(REMOTE_HOST):8000/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model":"tts-1","voice":"alloy","input":"Raccoon mission TTS test"}' \
-o /tmp/raccoon_test.mp3
@echo "✅ Test complete! Playing audio..."
@firefox /tmp/raccoon_test.mp3 || mpv /tmp/raccoon_test.mp3 || echo "Install firefox or mpv to play audio"
voices: voices-piper voices-xtts
@echo "✅ All voices downloaded!"
voices-piper:
@echo "🎤 Downloading Piper voices with correct directory structure..."
ssh $(REMOTE_USER)@$(REMOTE_HOST) "docker exec $(CONTAINER_NAME) bash -c '\
mkdir -p /app/voices/en/en_US/libritts_r/medium && \
cd /app/voices/en/en_US/libritts_r/medium && \
curl -L https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/libritts_r/medium/en_US-libritts_r-medium.onnx -o en_US-libritts_r-medium.onnx && \
curl -L https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/libritts_r/medium/en_US-libritts_r-medium.onnx.json -o en_US-libritts_r-medium.onnx.json && \
mkdir -p /app/voices/en/en_GB/northern_english_male/medium && \
cd /app/voices/en/en_GB/northern_english_male/medium && \
curl -L https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_GB/northern_english_male/medium/en_GB-northern_english_male-medium.onnx -o en_GB-northern_english_male-medium.onnx && \
curl -L https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_GB/northern_english_male/medium/en_GB-northern_english_male-medium.onnx.json -o en_GB-northern_english_male-medium.onnx.json'"
@echo "📝 Updating voice_to_speaker.yaml with ABSOLUTE paths..."
ssh $(REMOTE_USER)@$(REMOTE_HOST) "docker exec $(CONTAINER_NAME) bash -c '\
sed -i \"s|model: voices/en_US-libritts_r-medium.onnx|model: /app/voices/en/en_US/libritts_r/medium/en_US-libritts_r-medium.onnx|g\" /app/config/voice_to_speaker.yaml && \
sed -i \"s|model: voices/en_GB-northern_english_male-medium.onnx|model: /app/voices/en/en_GB/northern_english_male/medium/en_GB-northern_english_male-medium.onnx|g\" /app/config/voice_to_speaker.yaml'"
@echo "✅ Piper voices installed with absolute paths!"
voices-xtts:
@echo "🎤 Downloading XTTS speaker samples..."
ssh $(REMOTE_USER)@$(REMOTE_HOST) "docker exec $(CONTAINER_NAME) bash -c 'cd /app && ./scripts/download_samples.sh'"
@echo "✅ XTTS speaker samples downloaded!"
test-xtts:
@echo "🧪 Testing XTTS HD endpoint (this may take 1-2 minutes on first run)..."
curl -X POST http://$(REMOTE_HOST):8000/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model":"tts-1-hd","voice":"alloy","input":"Testing XTTS high definition"}' \
-o /tmp/xtts_test.mp3
@echo "✅ Test complete! Playing audio..."
@firefox /tmp/xtts_test.mp3 || mpv /tmp/xtts_test.mp3 || echo "Install firefox or mpv to play audio"