forked from KoljaB/RealtimeVoiceChat
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_app.sh
More file actions
150 lines (125 loc) Β· 4.66 KB
/
Copy pathstart_app.sh
File metadata and controls
150 lines (125 loc) Β· 4.66 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
#!/bin/bash
# start_app.sh - Robust startup script for RealtimeVoiceChat
# Ensures all dependencies are ready before launching the application
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
NC='\033[0m' # No Color
echo -e "${PURPLE}π€π Starting RealtimeVoiceChat Application${NC}"
echo -e "${PURPLE}=========================================${NC}"
echo ""
# Configuration
OLLAMA_PORT=11434
TTS_PORT=1234
OLLAMA_MODEL="mistral:7b"
# Step 1: Check and start Ollama
echo -e "${YELLOW}π¦ Step 1: Checking Ollama service...${NC}"
# Check if Ollama is installed
if ! command -v ollama &> /dev/null; then
echo -e "${RED}β Ollama not found. Please run setup_complete.sh first${NC}"
exit 1
fi
# Check if Ollama service is running
if ! pgrep -f "ollama serve" > /dev/null; then
echo -e "${BLUE}π Starting Ollama service...${NC}"
nohup ollama serve > /tmp/ollama.log 2>&1 &
# Wait for service to start
echo -e "${BLUE}β³ Waiting for Ollama service...${NC}"
for i in {1..30}; do
if curl -s http://localhost:${OLLAMA_PORT}/api/tags > /dev/null 2>&1; then
echo -e "${GREEN}β
Ollama service started${NC}"
break
fi
if [ $i -eq 30 ]; then
echo -e "${RED}β Ollama service failed to start${NC}"
echo -e "${BLUE}π Ollama log:${NC}"
tail -10 /tmp/ollama.log
exit 1
fi
sleep 1
done
else
echo -e "${GREEN}β
Ollama service already running${NC}"
fi
# Check if model is available
echo -e "${BLUE}π Checking Ollama model...${NC}"
if ollama list | grep -q "${OLLAMA_MODEL}"; then
echo -e "${GREEN}β
${OLLAMA_MODEL} model available${NC}"
else
echo -e "${YELLOW}β¬ Downloading ${OLLAMA_MODEL} model...${NC}"
ollama pull ${OLLAMA_MODEL}
if ollama list | grep -q "${OLLAMA_MODEL}"; then
echo -e "${GREEN}β
${OLLAMA_MODEL} model downloaded${NC}"
else
echo -e "${RED}β Failed to download ${OLLAMA_MODEL} model${NC}"
exit 1
fi
fi
# Step 2: Set audio environment
echo -e "${YELLOW}π Step 2: Setting up audio environment...${NC}"
# Source audio environment if available
if [ -f "set_audio_env.sh" ]; then
source set_audio_env.sh
echo -e "${GREEN}β
Audio environment configured${NC}"
else
echo -e "${BLUE}π§ Setting basic audio environment...${NC}"
export ALSA_PCM_CARD=default
export ALSA_PCM_DEVICE=0
export PULSE_RUNTIME_PATH=/tmp/pulse-runtime
export SDL_AUDIODRIVER=pulse
echo -e "${GREEN}β
Basic audio environment set${NC}"
fi
# Step 3: Check TTS server (optional)
echo -e "${YELLOW}π€ Step 3: Checking TTS server...${NC}"
if curl -s http://localhost:${TTS_PORT}/health > /dev/null 2>&1; then
echo -e "${GREEN}β
TTS server already running on port ${TTS_PORT}${NC}"
elif netstat -tuln | grep -q ":${TTS_PORT} "; then
echo -e "${GREEN}β
Port ${TTS_PORT} is in use (assuming TTS server)${NC}"
else
echo -e "${YELLOW}β οΈ TTS server not running on port ${TTS_PORT}${NC}"
echo -e "${BLUE}π‘ TTS will be started automatically or you can start manually:${NC}"
echo -e "${BLUE} python -m llama_cpp.server --model /workspace/models/Orpheus-3b-FT-Q8_0.gguf --host 0.0.0.0 --port ${TTS_PORT} --n_gpu_layers -1${NC}"
fi
# Step 4: Final checks
echo -e "${YELLOW}π§ͺ Step 4: Running final checks...${NC}"
# Check Python dependencies
echo -e "${BLUE}π Checking Python dependencies...${NC}"
cd code
python3 -c "
import sys
critical_packages = ['fastapi', 'uvicorn', 'whisper', 'torch', 'requests']
missing = []
for package in critical_packages:
try:
__import__(package)
except ImportError:
missing.append(package)
if missing:
print(f'β Missing packages: {missing}')
print('Please run: pip install -r ../requirements.txt')
sys.exit(1)
else:
print('β
All critical packages available')
"
if [ $? -ne 0 ]; then
echo -e "${RED}β Python dependency check failed${NC}"
exit 1
fi
# Step 5: Start the application
echo -e "${YELLOW}π Step 5: Starting RealtimeVoiceChat application...${NC}"
echo ""
echo -e "${GREEN}π All dependencies ready! Starting application...${NC}"
echo -e "${BLUE}π Configuration:${NC}"
echo -e " β’ Ollama: β
Running on port ${OLLAMA_PORT}"
echo -e " β’ Model: β
${OLLAMA_MODEL}"
echo -e " β’ Audio: β
Environment configured"
echo -e " β’ TTS: π Will start automatically or use manual server"
echo ""
echo -e "${PURPLE}π€ Starting RealtimeVoiceChat server...${NC}"
echo -e "${PURPLE}====================================${NC}"
# Start the application
exec python3 server.py