-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (132 loc) · 4.7 KB
/
Makefile
File metadata and controls
155 lines (132 loc) · 4.7 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
.PHONY: help install download-model serve server tts tts-clone tts-design test build rebuild up down logs health shell clean
# Detect docker compose command (v2 with space vs v1 with hyphen)
DOCKER_COMPOSE := $(shell docker compose version > /dev/null 2>&1 && echo "docker compose" || echo "docker-compose")
# Default target
help:
@echo "TTS Adapter"
@echo "==========="
@echo ""
@echo "Local (no Docker):"
@echo " make install - Install deps (uv sync)"
@echo " make download-model - Download model for offline use"
@echo " make serve - Run server locally (Ctrl+C to stop)"
@echo " make server stop - Kill local server"
@echo " make tts text=\"...\" [instruct=\"...\"] - Generate speech"
@echo " make tts-clone text=\"...\" ref=sample.wav - Clone voice (Base model)"
@echo " make tts-design text=\"...\" instruct=\"...\" - Design voice (VoiceDesign model)"
@echo " make test - Test single TTS generation"
@echo " make test batch - Test batch TTS generation"
@echo ""
@echo "Docker:"
@echo " make build - Build GPU image (online, one-time)"
@echo " make rebuild - Force rebuild with no cache"
@echo " make up - Start container (offline; reuses cached image)"
@echo " make down - Stop container"
@echo " make logs - View logs"
@echo " make health - Test health endpoint"
@echo " make shell - Shell into container"
@echo ""
@echo "Cleanup:"
@echo " make clean - Remove output files"
# Install dependencies
install:
uv sync
@echo ""
@echo "Done! Now run: source .venv/bin/activate"
# Download model for offline use
download-model:
uv run python scripts/qwen3/download_model.py
# === LOCAL SERVER ===
serve:
uv run python -m tts_adapter.cli
server:
@$(eval ACTION := $(filter-out $@,$(MAKECMDGOALS)))
@if [ "$(ACTION)" = "stop" ]; then \
pkill -f "python.*tts_adapter" 2>/dev/null && echo "Server stopped" || echo "No server running"; \
else \
echo "Usage: make server stop"; \
fi
stop:
@:
# === TTS CLI ===
tts:
ifndef text
@echo "Usage: make tts text=\"Your text here\" [instruct=\"...\"]"
else
ifdef instruct
PYTHONPATH=. uv run python scripts/qwen3/tts.py "$(text)" --instruct "$(instruct)"
else
PYTHONPATH=. uv run python scripts/qwen3/tts.py "$(text)"
endif
endif
# Voice design (requires VoiceDesign model)
tts-design:
ifndef text
@echo "Usage: make tts-design text=\"Your text\" instruct=\"voice description\""
else ifndef instruct
@echo "Usage: make tts-design text=\"Your text\" instruct=\"voice description\""
else
PYTHONPATH=. uv run python scripts/qwen3/tts_design.py "$(text)" --instruct "$(instruct)"
endif
# Voice cloning (requires Base model)
tts-clone:
ifndef text
@echo "Usage: make tts-clone text=\"Your text\" ref=sample.wav"
else ifndef ref
@echo "Usage: make tts-clone text=\"Your text\" ref=sample.wav"
else
PYTHONPATH=. uv run python scripts/qwen3/tts_clone.py "$(text)" --ref "$(ref)"
endif
# === TEST ===
test:
@$(eval GOALS := $(filter-out $@,$(MAKECMDGOALS)))
@$(eval MODE := $(word 1,$(GOALS)))
@if [ "$(MODE)" = "batch" ]; then \
$(MAKE) -s _test-batch; \
elif [ -z "$(MODE)" ]; then \
$(MAKE) -s _test-single; \
else \
echo "Usage: make test [batch]"; \
fi
_test-single:
@echo "Testing single TTS generation..."
@curl -sf -X POST http://localhost:9880/tts \
-H 'content-type: application/json' \
-d '{"text":"Тест генерации","language":"Russian","speaker":"Ryan"}' \
--output /tmp/tts_test.wav \
&& echo "OK: /tmp/tts_test.wav" || echo "FAIL (is server running?)"
_test-batch:
@echo "Testing batch TTS generation..."
@curl -sf -X POST http://localhost:9880/tts/batch \
-H 'content-type: application/json' \
-d '{"items":[{"id":"001","text":"Первая фраза","language":"Russian","speaker":"Ryan"},{"id":"002","text":"Вторая фраза","language":"Russian","speaker":"Ryan"}]}' \
--output /tmp/tts_batch.zip \
&& echo "OK: /tmp/tts_batch.zip" || echo "FAIL (is server running?)"
batch:
@:
# === CLEAN ===
clean:
@echo "Cleaning temp files..."
rm -f /tmp/tts_*.wav /tmp/tts_*.zip
@echo "Done!"
# === DOCKER ===
# Build once online; `up` then runs offline via pull_policy: missing in compose.yml
build:
$(DOCKER_COMPOSE) --profile gpu build
rebuild:
$(DOCKER_COMPOSE) --profile gpu build --no-cache --pull
up:
$(DOCKER_COMPOSE) --profile gpu up -d --no-build
@sleep 2
@echo "Started. Run: make health"
down:
$(DOCKER_COMPOSE) --profile gpu down
logs:
$(DOCKER_COMPOSE) --profile gpu logs -f adapter-tts
health:
@echo "health: " && curl -sf http://localhost:9880/health && echo "" || echo "FAIL"
shell:
$(DOCKER_COMPOSE) --profile gpu exec adapter-tts bash
# Catch-all to allow arguments after commands
%:
@: