Skip to content

Commit eaf151e

Browse files
committed
Added functions to ensure streamlit app stays active
1 parent 77ca575 commit eaf151e

15 files changed

+641
-9
lines changed

.github/workflows/keep-alive.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Keep Streamlit App Alive
2+
3+
on:
4+
schedule:
5+
# Run every 6 hours to keep app active (more frequent than 12-hour hibernation)
6+
- cron: '0 */6 * * *'
7+
# Also run every 2 hours during business hours (9 AM - 5 PM UTC)
8+
- cron: '0 9-17/2 * * *'
9+
workflow_dispatch: # Allow manual trigger
10+
11+
jobs:
12+
ping-app:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Ping Streamlit App
16+
run: |
17+
echo "Pinging Streamlit app to keep it alive..."
18+
curl -f -s -o /dev/null https://clipabit-demo1.streamlit.app/ || {
19+
echo "Failed to ping app"
20+
exit 1
21+
}
22+
echo "Successfully pinged app - it will stay active with frequent monitoring!"

.streamlit/config.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[server]
2+
port = 8501
3+
address = "0.0.0.0"
4+
headless = true
5+
enableCORS = false
6+
enableXsrfProtection = false
7+
8+
[browser]
9+
gatherUsageStats = false
10+
serverAddress = "localhost"
11+
serverPort = 8501
12+
13+
[logger]
14+
level = "info"

.streamlit/secrets.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[general]
2+
email = "your-email@example.com"
3+
4+
# Add any API keys or secrets here
5+
# [secrets]
6+
# OPENAI_API_KEY = "your-openai-api-key"
7+
# HUGGINGFACE_API_KEY = "your-huggingface-api-key"

DEPLOYMENT.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Audio Transcription App - Streamlit Cloud Deployment
2+
3+
This repository is ready for deployment on Streamlit Cloud.
4+
5+
## Current Status
6+
7+
**Local App Running**: There's currently a Streamlit app running on http://localhost:8501
8+
**Repository Ready**: All necessary files are configured for cloud deployment
9+
**Dependencies Updated**: requirements.txt includes all needed packages with versions
10+
11+
## Files Created for Deployment
12+
13+
- `.streamlit/config.toml` - Streamlit configuration
14+
- `.streamlit/secrets.toml` - Template for environment variables
15+
- `requirements.txt` - Updated with specific versions for cloud deployment
16+
- `streamlit_app.py` - Your main application file
17+
18+
## Deploy to Streamlit Cloud
19+
20+
### Step 1: Push to GitHub
21+
```bash
22+
git add .
23+
git commit -m "Prepare for Streamlit Cloud deployment"
24+
git push origin main
25+
```
26+
27+
### Step 2: Deploy on Streamlit Cloud
28+
1. Go to [share.streamlit.io](https://share.streamlit.io)
29+
2. Click "New app"
30+
3. Connect your GitHub repository: `justinwu/audio-transcription`
31+
4. Select branch: `main`
32+
5. Main file path: `streamlit_app.py`
33+
6. Click "Deploy!"
34+
35+
### Step 3: Configure Secrets (if needed)
36+
If your app needs API keys or other secrets:
37+
1. Go to your deployed app's settings
38+
2. Add secrets in the format:
39+
```toml
40+
[secrets]
41+
OPENAI_API_KEY = "your-key-here"
42+
```
43+
44+
## Local Development
45+
46+
### Start Local Server
47+
```bash
48+
# Using the management script
49+
./run_streamlit.sh start
50+
51+
# Or manually
52+
streamlit run streamlit_app.py
53+
```
54+
55+
### Stop Current Server
56+
```bash
57+
# Stop the management script version
58+
./run_streamlit.sh stop
59+
60+
# Or kill the current process
61+
kill 36506 # Replace with actual PID
62+
```
63+
64+
## App Features
65+
66+
- **Audio Transcription**: Upload MP3, WAV, MP4 files
67+
- **Semantic Search**: Search through transcripts using different algorithms
68+
- **Embedding Comparison**: Compare text, audio, and visual embeddings
69+
- **Real-time Processing**: Live transcription with Whisper AI
70+
71+
## Troubleshooting
72+
73+
1. **FFmpeg Issues**: The app checks for FFmpeg availability
74+
2. **Model Loading**: Whisper models are loaded on-demand
75+
3. **File Upload**: Supports multiple file formats
76+
4. **Memory Usage**: Large files may require more memory
77+
78+
## Next Steps
79+
80+
1. Test locally: `./run_streamlit.sh start`
81+
2. Push to GitHub
82+
3. Deploy on Streamlit Cloud
83+
4. Share your new app URL!

KEEP_ALIVE_SETUP.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Keep Streamlit App Active - Ping Service Setup
2+
3+
## Option 1: UptimeRobot (Free)
4+
1. Go to [uptimerobot.com](https://uptimerobot.com)
5+
2. Sign up for free account
6+
3. Add new monitor:
7+
- Monitor Type: HTTP(s)
8+
- Friendly Name: "ClipABit Demo Keep Alive"
9+
- URL: https://clipabit-demo1.streamlit.app/
10+
- Monitoring Interval: 5 minutes
11+
- Monitor Timeout: 30 seconds
12+
13+
## Option 2: Pingdom (Free Tier)
14+
1. Go to [pingdom.com](https://pingdom.com)
15+
2. Create free account
16+
3. Add new check:
17+
- URL: https://clipabit-demo1.streamlit.app/
18+
- Check interval: 1 minute
19+
- Locations: Choose closest to you
20+
21+
## Option 3: GitHub Actions (Automated)
22+
Create a workflow that pings your app every 10 hours:
23+
24+
```yaml
25+
name: Keep Streamlit App Alive
26+
on:
27+
schedule:
28+
- cron: '0 */10 * * *' # Every 10 hours
29+
workflow_dispatch:
30+
31+
jobs:
32+
ping:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Ping Streamlit App
36+
run: |
37+
curl -f https://clipabit-demo1.streamlit.app/ || exit 1
38+
```
39+
40+
## Option 4: Simple Cron Job (If you have a server)
41+
```bash
42+
# Add to crontab (crontab -e)
43+
0 */6 * * * curl -s https://clipabit-demo1.streamlit.app/ > /dev/null
44+
```
45+
46+
## Option 5: Browser Automation
47+
Use a service like Browserless or Puppeteer to simulate real visits.
48+
49+
## Important Notes:
50+
- Streamlit Cloud hibernates apps after 12 hours of inactivity
51+
- These methods help prevent hibernation
52+
- Free services may have limitations
53+
- Consider upgrading to paid hosting for guaranteed uptime

README.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,71 @@ The sidebar provides live data on the following metrics for each search and embe
5252
- **Computational Intensity**: Resource usage for each operation.
5353
## Live Demo
5454

55-
[![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/justinwuzijin/clipabit-demo1/main/streamlit_app.py)
55+
### 🚀 **Currently Running**
56+
**Local Development**: [http://localhost:8501](http://localhost:8501) *(Running locally)*
57+
58+
### 🌐 **Cloud Deployment**
59+
[![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/justinwuzijin/clipabit-demo1/main/streamlit_app.py) *(Previous demo)*
60+
61+
**Status**: ✅ **Always Active** - Monitored by UptimeRobot to prevent hibernation
62+
63+
**New Deployment**: *Coming soon - deploy this repository to get your own dedicated URL*
5664

5765
### How to Run
5866

67+
#### Option 1: Using Management Script (Recommended)
68+
```bash
69+
# Start the app in background
70+
./run_streamlit.sh start
71+
72+
# Check status
73+
./run_streamlit.sh status
74+
75+
# View logs
76+
./run_streamlit.sh logs
77+
78+
# Stop the app
79+
./run_streamlit.sh stop
80+
```
81+
82+
#### Option 2: Manual Start
5983
1. Install dependencies:
6084
```bash
61-
pip install openai-whisper scikit-learn streamlit
85+
pip install -r requirements.txt
6286
```
6387
2. Start the app:
6488
```bash
6589
streamlit run streamlit_app.py
6690
```
6791

92+
#### Option 3: Deploy to Streamlit Cloud
93+
1. Push to GitHub:
94+
```bash
95+
git add .
96+
git commit -m "Deploy to Streamlit Cloud"
97+
git push origin main
98+
```
99+
2. Go to [share.streamlit.io](https://share.streamlit.io) and deploy!
100+
101+
## 🔄 **Keeping Apps Active**
102+
103+
### Prevent Streamlit Cloud Hibernation
104+
Streamlit Cloud hibernates apps after 12 hours of inactivity. To keep apps always running:
105+
106+
#### Option 1: UptimeRobot (Recommended)
107+
1. Go to [uptimerobot.com](https://uptimerobot.com)
108+
2. Add monitor for your app URL
109+
3. Set 5-minute intervals
110+
4. App stays active forever! ✅
111+
112+
#### Option 2: GitHub Actions
113+
Use the included workflow: `.github/workflows/keep-alive.yml`
114+
115+
#### Option 3: Manual Ping
116+
Run the included script: `./ping_app.sh`
117+
118+
**Files**: See `UPTIMEROBOT_SETUP.md` for detailed instructions.
119+
68120
### Next Steps
69121

70122
- Implement and compare the search algorithms listed above.

STREAMLIT_SETUP.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Streamlit App Management
2+
3+
This directory contains scripts and configurations to run your Audio Transcription Streamlit app continuously.
4+
5+
## Quick Start
6+
7+
### Option 1: Using the Management Script (Recommended)
8+
9+
```bash
10+
# Start the app in background
11+
./run_streamlit.sh start
12+
13+
# Check if it's running
14+
./run_streamlit.sh status
15+
16+
# View logs
17+
./run_streamlit.sh logs
18+
19+
# Stop the app
20+
./run_streamlit.sh stop
21+
22+
# Restart the app
23+
./run_streamlit.sh restart
24+
```
25+
26+
### Option 2: Manual Background Process
27+
28+
```bash
29+
# Run in background with nohup
30+
nohup streamlit run streamlit_app.py --server.port 8501 --server.address 0.0.0.0 > streamlit.log 2>&1 &
31+
32+
# Check if running
33+
ps aux | grep streamlit
34+
35+
# Stop by finding PID and killing it
36+
kill <PID>
37+
```
38+
39+
### Option 3: Using screen/tmux (for development)
40+
41+
```bash
42+
# Using screen
43+
screen -S streamlit
44+
streamlit run streamlit_app.py --server.port 8501 --server.address 0.0.0.0
45+
# Press Ctrl+A, D to detach
46+
47+
# Using tmux
48+
tmux new-session -d -s streamlit
49+
tmux send-keys -t streamlit "streamlit run streamlit_app.py --server.port 8501 --server.address 0.0.0.0" Enter
50+
```
51+
52+
## Access Your App
53+
54+
Once running, access your app at: http://localhost:8501
55+
56+
## Files Created
57+
58+
- `run_streamlit.sh` - Management script for starting/stopping the app
59+
- `.streamlit/config.toml` - Streamlit configuration
60+
- `streamlit.service` - Systemd service file (for Linux systems)
61+
- `streamlit.log` - Log file (created when app runs)
62+
63+
## Troubleshooting
64+
65+
1. **Port already in use**: Change the port in the script or kill the existing process
66+
2. **Permission denied**: Make sure the script is executable (`chmod +x run_streamlit.sh`)
67+
3. **Dependencies missing**: Install requirements with `pip install -r requirements.txt`
68+
4. **FFmpeg issues**: Install FFmpeg with `brew install ffmpeg` (macOS) or your system's package manager

0 commit comments

Comments
 (0)