forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_server.sh
More file actions
executable file
·101 lines (85 loc) · 2.65 KB
/
Copy pathstart_server.sh
File metadata and controls
executable file
·101 lines (85 loc) · 2.65 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
#!/bin/bash
# Script to start FastAPI server with ngrok tunnel
echo "🚀 Starting Omi Audio Streaming Service with Hume AI..."
echo ""
# Check if .env file exists
if [ ! -f .env ]; then
echo "❌ Error: .env file not found!"
echo "Please copy .env.example to .env and add your HUME_API_KEY"
echo "Run: cp .env.example .env"
exit 1
fi
# Check if HUME_API_KEY is set
source .env
if [ -z "$HUME_API_KEY" ] || [ "$HUME_API_KEY" = "your_hume_api_key_here" ]; then
echo "❌ Error: HUME_API_KEY not configured in .env file!"
echo "Please edit .env and add your Hume AI API key"
exit 1
fi
echo "✓ Environment variables loaded"
echo ""
# Start FastAPI server in background
echo "📡 Starting FastAPI server on port 8080..."
python main.py > server.log 2>&1 &
SERVER_PID=$!
echo "✓ Server started (PID: $SERVER_PID)"
# Wait for server to be ready
echo "⏳ Waiting for server to start..."
sleep 3
# Check if server is running
if ! kill -0 $SERVER_PID 2>/dev/null; then
echo "❌ Server failed to start. Check server.log for errors:"
cat server.log
exit 1
fi
echo "✓ Server is running"
echo ""
# Start ngrok tunnel
echo "🌐 Starting ngrok tunnel..."
ngrok http 8080 > ngrok.log 2>&1 &
NGROK_PID=$!
echo "✓ Ngrok started (PID: $NGROK_PID)"
# Wait for ngrok to be ready
sleep 3
# Get ngrok URL
echo "⏳ Getting ngrok URL..."
NGROK_URL=$(curl -s http://localhost:4040/api/tunnels | grep -o '"public_url":"https://[^"]*' | grep -o 'https://[^"]*' | head -1)
if [ -z "$NGROK_URL" ]; then
echo "❌ Failed to get ngrok URL"
echo "You can manually check at: http://localhost:4040"
else
echo ""
echo "============================================"
echo "✅ Server is running!"
echo "============================================"
echo ""
echo "📍 Local URL: http://localhost:8080"
echo "🌐 Public URL: $NGROK_URL"
echo ""
echo "📋 CONFIGURE YOUR OMI DEVICE:"
echo "1. Open the Omi App"
echo "2. Go to Settings → Developer Mode"
echo "3. Set 'Realtime audio bytes' to:"
echo " $NGROK_URL/audio"
echo "4. Set 'Every x seconds' to your desired interval (e.g., 10)"
echo ""
echo "============================================"
echo ""
echo "📊 Monitoring:"
echo " - Server logs: tail -f server.log"
echo " - Ngrok dashboard: http://localhost:4040"
echo ""
echo "🛑 To stop: Press Ctrl+C or run: pkill -P $$ "
echo ""
fi
# Function to cleanup on exit
cleanup() {
echo ""
echo "🛑 Shutting down..."
kill $SERVER_PID 2>/dev/null
kill $NGROK_PID 2>/dev/null
echo "✓ Stopped"
}
trap cleanup EXIT INT TERM
# Keep script running
wait