-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch.sh
More file actions
executable file
·325 lines (296 loc) · 12.9 KB
/
Copy pathlaunch.sh
File metadata and controls
executable file
·325 lines (296 loc) · 12.9 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#!/bin/bash
# SongBloom One-Click Setup and Launch Script
# Supports both Streamlit and Gradio interfaces
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Banner
echo -e "${BLUE}"
cat << "EOF"
╔═══════════════════════════════════════════════════════════════╗
║ ║
║ 🎵 SongBloom One-Click Setup & Launch 🎵 ║
║ ║
║ Choose your interface and get started! ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
EOF
echo -e "${NC}"
# Function to check if conda is available
check_conda() {
if command -v conda &> /dev/null; then
return 0
else
return 1
fi
}
# Function to check if virtual environment exists
check_venv() {
if [ -d "venv" ]; then
return 0
else
return 1
fi
}
# Function to create conda environment
setup_conda_env() {
echo -e "${YELLOW}Setting up Conda environment...${NC}"
if conda env list | grep -q "^songbloom "; then
echo -e "${GREEN}Conda environment 'songbloom' already exists.${NC}"
read -p "Do you want to recreate it? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
conda env remove -n songbloom -y
conda create -n songbloom python=3.8.12 -y
fi
else
conda create -n songbloom python=3.8.12 -y
fi
echo -e "${GREEN}✓ Conda environment ready${NC}"
}
# Function to create virtual environment
setup_venv() {
echo -e "${YELLOW}Setting up Python virtual environment...${NC}"
if check_venv; then
echo -e "${GREEN}Virtual environment already exists.${NC}"
read -p "Do you want to recreate it? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf venv
python -m venv venv
fi
else
python -m venv venv
fi
echo -e "${GREEN}✓ Virtual environment ready${NC}"
}
# Function to install dependencies
install_dependencies() {
local interface=$1
echo -e "${YELLOW}Installing dependencies for $interface...${NC}"
if [ "$interface" == "streamlit" ]; then
echo -e "${BLUE}Installing Streamlit requirements...${NC}"
pip install -r requirements.txt
else
echo -e "${BLUE}Installing Gradio requirements...${NC}"
cd SongBloom-master
pip install -r requirements.txt
cd ..
# Also install streamlit requirements for dual support
pip install streamlit>=1.28.0
fi
echo -e "${GREEN}✓ Dependencies installed${NC}"
}
# Function to activate environment
activate_env() {
local env_type=$1
if [ "$env_type" == "conda" ]; then
echo -e "${YELLOW}Activating Conda environment...${NC}"
eval "$(conda shell.bash hook)"
conda activate songbloom
else
echo -e "${YELLOW}Activating virtual environment...${NC}"
source venv/bin/activate
fi
}
# Function to launch Streamlit
launch_streamlit() {
echo -e "${GREEN}"
cat << "EOF"
╔═══════════════════════════════════════════════════════════════╗
║ Launching Streamlit Interface ║
╚═══════════════════════════════════════════════════════════════╝
EOF
echo -e "${NC}"
echo -e "${BLUE}Starting Streamlit app...${NC}"
echo -e "${YELLOW}Access the app at: http://localhost:8501${NC}"
echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
echo ""
streamlit run streamlit_app.py
}
# Function to launch Gradio
launch_gradio() {
echo -e "${GREEN}"
cat << "EOF"
╔═══════════════════════════════════════════════════════════════╗
║ Launching Gradio Interface ║
╚═══════════════════════════════════════════════════════════════╝
EOF
echo -e "${NC}"
echo -e "${BLUE}Starting Gradio app...${NC}"
echo -e "${YELLOW}Access the app at: http://localhost:7860${NC}"
echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
echo ""
cd SongBloom-master
python app.py --auto-load-model
}
# Function to launch Next-Gen X3
launch_x3() {
echo -e "${GREEN}"
cat << "EOF"
╔═══════════════════════════════════════════════════════════════╗
║ Launching Next-Gen X3 Interface ║
╚═══════════════════════════════════════════════════════════════╝
EOF
echo -e "${NC}"
echo -e "${BLUE}Starting Next-Gen X3 app...${NC}"
echo -e "${YELLOW}Access the app at: http://localhost:7860${NC}"
echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
echo ""
cd SongBloom-master
python app_nextgen_x3.py --auto-load-model
}
# Main menu
show_menu() {
echo -e "${BLUE}"
echo "╔═══════════════════════════════════════════════════════════════╗"
echo "║ Choose Your Interface ║"
echo "╠═══════════════════════════════════════════════════════════════╣"
echo "║ ║"
echo "║ 1. 🌐 Streamlit (Modern, Cloud-Ready) ║"
echo "║ - Best for: Cloud deployment, sharing ║"
echo "║ - Port: 8501 ║"
echo "║ ║"
echo "║ 2. 🎨 Gradio (Suno-like GUI) ║"
echo "║ - Best for: Local use, familiar interface ║"
echo "║ - Port: 7860 ║"
echo "║ ║"
echo "║ 3. 🎤 Next-Gen X3 (Voice Personas) ║"
echo "║ - Best for: Voice cloning, advanced features ║"
echo "║ - Port: 7860 ║"
echo "║ ║"
echo "║ 4. ⚙️ Setup Only (Install dependencies) ║"
echo "║ ║"
echo "║ 5. 🚪 Exit ║"
echo "║ ║"
echo "╚═══════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
}
# Environment setup menu
show_env_menu() {
echo -e "${BLUE}"
echo "╔═══════════════════════════════════════════════════════════════╗"
echo "║ Environment Setup Method ║"
echo "╠═══════════════════════════════════════════════════════════════╣"
echo "║ ║"
echo "║ 1. 🐍 Conda (Recommended) ║"
echo "║ - Better dependency management ║"
echo "║ - Isolated environment ║"
echo "║ ║"
echo "║ 2. 📦 Virtual Environment (venv) ║"
echo "║ - Lightweight ║"
echo "║ - Standard Python tool ║"
echo "║ ║"
echo "║ 3. 🔄 Skip (Use existing environment) ║"
echo "║ ║"
echo "╚═══════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
}
# Main execution
main() {
# Check if setup is needed
SKIP_SETUP=false
if [ ! -f ".songbloom_setup_complete" ]; then
echo -e "${YELLOW}First time setup detected!${NC}"
# Show environment menu
show_env_menu
read -p "Choose setup method (1-3): " env_choice
case $env_choice in
1)
if ! check_conda; then
echo -e "${RED}Error: Conda not found. Please install Miniconda or Anaconda first.${NC}"
echo -e "${YELLOW}Download from: https://docs.conda.io/en/latest/miniconda.html${NC}"
exit 1
fi
setup_conda_env
activate_env "conda"
;;
2)
setup_venv
activate_env "venv"
;;
3)
echo -e "${YELLOW}Skipping environment setup...${NC}"
SKIP_SETUP=true
;;
*)
echo -e "${RED}Invalid choice. Exiting.${NC}"
exit 1
;;
esac
# Show interface menu for dependency installation
if [ "$SKIP_SETUP" = false ]; then
echo ""
echo -e "${YELLOW}Which interface(s) do you want to use?${NC}"
echo "1. Streamlit only"
echo "2. Gradio only"
echo "3. Both (recommended)"
read -p "Choose (1-3): " dep_choice
case $dep_choice in
1)
install_dependencies "streamlit"
;;
2)
install_dependencies "gradio"
;;
3)
install_dependencies "gradio" # This installs both
;;
*)
echo -e "${RED}Invalid choice. Installing both...${NC}"
install_dependencies "gradio"
;;
esac
# Mark setup as complete
touch .songbloom_setup_complete
echo -e "${GREEN}✓ Setup complete!${NC}"
fi
else
echo -e "${GREEN}✓ Environment already set up${NC}"
# Try to activate existing environment
if check_conda && conda env list | grep -q "^songbloom "; then
activate_env "conda"
elif check_venv; then
activate_env "venv"
fi
fi
# Show main menu
while true; do
echo ""
show_menu
read -p "Enter your choice (1-5): " choice
case $choice in
1)
launch_streamlit
;;
2)
launch_gradio
;;
3)
launch_x3
;;
4)
echo -e "${YELLOW}Running setup...${NC}"
rm -f .songbloom_setup_complete
exec "$0" # Restart script
;;
5)
echo -e "${GREEN}Goodbye! 👋${NC}"
exit 0
;;
*)
echo -e "${RED}Invalid choice. Please try again.${NC}"
;;
esac
# After app exits, return to menu
echo ""
echo -e "${YELLOW}App stopped. Returning to menu...${NC}"
sleep 2
done
}
# Run main function
main