forked from KoljaB/RealtimeVoiceChat
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_complete.sh
More file actions
249 lines (206 loc) Β· 6.29 KB
/
setup_complete.sh
File metadata and controls
249 lines (206 loc) Β· 6.29 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
#!/bin/bash
# setup_complete.sh - Complete setup for RealtimeVoiceChat application
# This script handles all dependencies: Ollama, Whisper models, Python packages, and system audio
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}π€π RealtimeVoiceChat Complete Setup${NC}"
echo -e "${PURPLE}====================================${NC}"
echo ""
# Configuration
WHISPER_MODEL="base" # Options: tiny, base, small, medium, large
OLLAMA_MODEL="mistral:7b"
MODELS_DIR="/workspace/models"
echo -e "${BLUE}π Setup Plan:${NC}"
echo -e " 1. System dependencies and audio libraries"
echo -e " 2. Python dependencies"
echo -e " 3. Ollama installation and model setup"
echo -e " 4. Whisper model download"
echo -e " 5. Audio system configuration"
echo -e " 6. Verification tests"
echo ""
# Step 1: System Dependencies
echo -e "${YELLOW}π¦ Step 1: Installing system dependencies...${NC}"
# Update package list
apt-get update -qq
# Install essential packages
echo -e "${BLUE}π§ Installing essential packages...${NC}"
apt-get install -y -qq \
curl \
wget \
git \
build-essential \
cmake \
pkg-config \
software-properties-common \
ca-certificates \
gnupg \
lsb-release
# Install audio libraries
echo -e "${BLUE}π Installing audio libraries...${NC}"
apt-get install -y -qq \
libsndfile1-dev \
portaudio19-dev \
libasound2-dev \
libpulse-dev \
alsa-utils \
pulseaudio \
ffmpeg
# Install Python development packages
echo -e "${BLUE}π Installing Python development packages...${NC}"
apt-get install -y -qq \
python3-dev \
python3-pip \
python3-venv
echo -e "${GREEN}β
System dependencies installed${NC}"
# Step 2: Python Dependencies
echo -e "${YELLOW}π Step 2: Installing Python dependencies...${NC}"
# Upgrade pip
pip install --upgrade pip
# Install core dependencies
echo -e "${BLUE}π¦ Installing core Python packages...${NC}"
pip install -r requirements.txt
echo -e "${GREEN}β
Python dependencies installed${NC}"
# Step 3: Ollama Setup
echo -e "${YELLOW}π¦ Step 3: Setting up Ollama...${NC}"
# Make setup script executable and run it
chmod +x setup_ollama.sh
./setup_ollama.sh
echo -e "${GREEN}β
Ollama setup completed${NC}"
# Step 4: Whisper Model Download
echo -e "${YELLOW}ποΈ Step 4: Setting up Whisper models...${NC}"
# Create models directory
mkdir -p ${MODELS_DIR}
# Download Whisper model using Python
echo -e "${BLUE}β¬ Downloading Whisper ${WHISPER_MODEL} model...${NC}"
python3 -c "
import whisper
import os
model_name = '${WHISPER_MODEL}'
models_dir = '${MODELS_DIR}'
print(f'Downloading Whisper {model_name} model...')
try:
model = whisper.load_model(model_name, download_root=models_dir)
print(f'β
Whisper {model_name} model downloaded successfully')
except Exception as e:
print(f'β Error downloading Whisper model: {e}')
exit(1)
"
echo -e "${GREEN}β
Whisper model setup completed${NC}"
# Step 5: Audio System Configuration
echo -e "${YELLOW}π Step 5: Configuring audio system...${NC}"
# Create ALSA configuration to suppress warnings
echo -e "${BLUE}π§ Configuring ALSA...${NC}"
cat > /etc/asound.conf << 'EOF'
# ALSA configuration to suppress warnings
pcm.!default {
type pulse
fallback "sysdefault"
hint {
show on
description "Default ALSA Output (currently PulseAudio Sound Server)"
}
}
ctl.!default {
type pulse
fallback "sysdefault"
}
# Suppress ALSA warnings
pcm.null {
type null
}
EOF
# Set environment variables to suppress ALSA warnings
echo -e "${BLUE}π§ Setting audio environment variables...${NC}"
cat >> ~/.bashrc << 'EOF'
# Suppress ALSA warnings for RealtimeVoiceChat
export ALSA_PCM_CARD=default
export ALSA_PCM_DEVICE=0
export PULSE_RUNTIME_PATH=/tmp/pulse-runtime
EOF
# Create audio environment script
cat > set_audio_env.sh << 'EOF'
#!/bin/bash
# Audio environment setup for RealtimeVoiceChat
export ALSA_PCM_CARD=default
export ALSA_PCM_DEVICE=0
export PULSE_RUNTIME_PATH=/tmp/pulse-runtime
export SDL_AUDIODRIVER=pulse
EOF
chmod +x set_audio_env.sh
echo -e "${GREEN}β
Audio system configured${NC}"
# Step 6: Verification
echo -e "${YELLOW}π§ͺ Step 6: Running verification tests...${NC}"
# Test Python imports
echo -e "${BLUE}π Testing Python imports...${NC}"
python3 -c "
import sys
import traceback
packages = [
'whisper',
'torch',
'numpy',
'scipy',
'transformers',
'requests',
'fastapi',
'uvicorn',
'soundfile',
'pyaudio'
]
failed = []
for package in packages:
try:
__import__(package)
print(f'β
{package}')
except ImportError as e:
print(f'β {package}: {e}')
failed.append(package)
if failed:
print(f'\\nβ Failed imports: {failed}')
sys.exit(1)
else:
print('\\nβ
All Python packages imported successfully')
"
# Test Ollama
echo -e "${BLUE}π Testing Ollama...${NC}"
if curl -s http://localhost:11434/api/tags > /dev/null; then
echo -e "${GREEN}β
Ollama API responding${NC}"
else
echo -e "${RED}β Ollama API not responding${NC}"
fi
# Test Whisper model
echo -e "${BLUE}π Testing Whisper model...${NC}"
python3 -c "
import whisper
import os
try:
model = whisper.load_model('${WHISPER_MODEL}', download_root='${MODELS_DIR}')
print('β
Whisper model loaded successfully')
except Exception as e:
print(f'β Error loading Whisper model: {e}')
"
echo ""
echo -e "${GREEN}π RealtimeVoiceChat setup completed successfully!${NC}"
echo ""
echo -e "${BLUE}π Summary:${NC}"
echo -e " β’ System dependencies: β
Installed"
echo -e " β’ Python packages: β
Installed"
echo -e " β’ Ollama service: β
Running on port 11434"
echo -e " β’ Ollama model: β
${OLLAMA_MODEL}"
echo -e " β’ Whisper model: β
${WHISPER_MODEL}"
echo -e " β’ Audio system: β
Configured"
echo ""
echo -e "${YELLOW}π Ready to start RealtimeVoiceChat!${NC}"
echo -e "${BLUE}π‘ To start the application:${NC}"
echo -e " cd code"
echo -e " source ../set_audio_env.sh"
echo -e " python server.py"
echo ""
echo -e "${BLUE}π‘ To manually start TTS server (if needed):${NC}"
echo -e " python -m llama_cpp.server --model ${MODELS_DIR}/Orpheus-3b-FT-Q8_0.gguf --host 0.0.0.0 --port 1234 --n_gpu_layers -1"