-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart
More file actions
executable file
·220 lines (188 loc) · 6.42 KB
/
start
File metadata and controls
executable file
·220 lines (188 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
set -e
# GraphDone-TTS Starter Script
# Usage: ./start [options]
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Print GraphDone banner
print_banner() {
echo -e "${CYAN}"
echo "╔════════════════════════════════════════╗"
echo "║ GraphDone-TTS Server ║"
echo "║ Text-to-Speech with Piper-TTS ║"
echo "╚════════════════════════════════════════╝"
echo -e "${NC}"
}
# Check if Docker is installed
check_docker() {
if ! command -v docker &> /dev/null; then
echo -e "${YELLOW}Docker not found. Installing Docker...${NC}"
./scripts/install_docker.sh
fi
}
# Check if voices are downloaded
check_voices() {
if [ ! -d "voices" ] || [ "$(ls -A voices/*.onnx 2>/dev/null | wc -l)" -lt "3" ]; then
echo -e "${YELLOW}Downloading voice models...${NC}"
./scripts/download_voices.sh
fi
}
# Auto-detect best start method
auto_start() {
echo -e "${GREEN}🚀 Starting GraphDone-TTS...${NC}"
# Check prerequisites
check_docker
check_voices
# Check if docker-compose is available
if command -v docker-compose &> /dev/null || docker compose version &> /dev/null 2>&1; then
echo -e "${BLUE}Starting with Docker Compose...${NC}"
# Use docker compose (v2) or docker-compose (v1)
if docker compose version &> /dev/null 2>&1; then
COMPOSE_CMD="docker compose"
else
COMPOSE_CMD="docker-compose"
fi
# Stop any existing containers
$COMPOSE_CMD --profile complete down 2>/dev/null || true
# Start the complete stack
$COMPOSE_CMD --profile complete up -d
echo -e "${GREEN}✓ Services starting up...${NC}"
sleep 3
# Check health
if curl -s http://localhost:8000/health > /dev/null 2>&1; then
echo -e "${GREEN}✅ API Server is running at: ${CYAN}http://localhost:8000${NC}"
echo -e "${GREEN}✅ API Docs available at: ${CYAN}http://localhost:8000/docs${NC}"
fi
if curl -s http://localhost:3000 > /dev/null 2>&1; then
echo -e "${GREEN}✅ Web UI is running at: ${CYAN}http://localhost:3000${NC}"
fi
else
# Fallback to direct Docker run
echo -e "${BLUE}Starting with Docker...${NC}"
# Build if image doesn't exist
if ! docker images | grep -q "tts-server-complete"; then
echo -e "${YELLOW}Building Docker image...${NC}"
docker build -f docker/Dockerfile.single -t tts-server-complete:latest .
fi
# Stop existing container
docker stop graphdone-tts 2>/dev/null || true
docker rm graphdone-tts 2>/dev/null || true
# Run container
docker run -d \
-p 8000:8000 \
-p 3000:3000 \
--name graphdone-tts \
--restart unless-stopped \
tts-server-complete:latest
echo -e "${GREEN}✅ GraphDone-TTS is running!${NC}"
echo -e "${GREEN} API: ${CYAN}http://localhost:8000${NC}"
echo -e "${GREEN} Web UI: ${CYAN}http://localhost:3000${NC}"
fi
echo ""
echo -e "${BLUE}Quick test:${NC}"
echo " curl http://localhost:8000/health"
echo ""
echo -e "${BLUE}Stop services:${NC}"
echo " ./start stop"
}
# Stop services
stop_services() {
echo -e "${YELLOW}Stopping GraphDone-TTS...${NC}"
# Try docker-compose first
if command -v docker-compose &> /dev/null || docker compose version &> /dev/null 2>&1; then
if docker compose version &> /dev/null 2>&1; then
docker compose --profile complete down
else
docker-compose --profile complete down
fi
fi
# Also stop direct container
docker stop graphdone-tts 2>/dev/null || true
docker rm graphdone-tts 2>/dev/null || true
echo -e "${GREEN}✓ Services stopped${NC}"
}
# Show logs
show_logs() {
if docker ps | grep -q graphdone-tts; then
docker logs -f graphdone-tts
elif command -v docker-compose &> /dev/null || docker compose version &> /dev/null 2>&1; then
if docker compose version &> /dev/null 2>&1; then
docker compose logs -f
else
docker-compose logs -f
fi
else
echo -e "${RED}No running services found${NC}"
fi
}
# Clean everything
clean_all() {
echo -e "${YELLOW}Cleaning up GraphDone-TTS...${NC}"
stop_services
# Remove images
docker rmi tts-server-complete:latest 2>/dev/null || true
docker rmi ghcr.io/matatonic/openedai-speech-min 2>/dev/null || true
# Clean volumes
docker volume rm graphdone-tts_tts-cache 2>/dev/null || true
echo -e "${GREEN}✓ Cleanup complete${NC}"
}
# Main execution
print_banner
# Parse command or auto-start
case "${1:-}" in
stop)
stop_services
;;
logs)
show_logs
;;
clean)
clean_all
;;
restart)
stop_services
auto_start
;;
status)
if curl -s http://localhost:8000/health > /dev/null 2>&1; then
echo -e "${GREEN}✅ API Server is running${NC}"
else
echo -e "${RED}❌ API Server is not running${NC}"
fi
if curl -s http://localhost:3000 > /dev/null 2>&1; then
echo -e "${GREEN}✅ Web UI is running${NC}"
else
echo -e "${RED}❌ Web UI is not running${NC}"
fi
;;
help|--help|-h)
echo "Usage: ./start [command]"
echo ""
echo "Commands:"
echo " (none) Auto-setup and start GraphDone-TTS"
echo " stop Stop all services"
echo " restart Restart all services"
echo " logs Show service logs"
echo " status Check service status"
echo " clean Clean up containers and images"
echo " help Show this help message"
echo ""
echo "Just run './start' to automatically set up and run everything!"
;;
"")
# No arguments - auto start
auto_start
;;
*)
echo -e "${RED}Unknown command: $1${NC}"
echo "Run './start help' for usage information"
exit 1
;;
esac