thecodeworm commited on
Commit
b62e05a
·
verified ·
1 Parent(s): 19cf379

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -144,7 +144,7 @@ class Config:
144
  CNN_CHECKPOINT = CHECKPOINT_DIR / HF_CHECKPOINT_FILENAME
145
 
146
  # Model configuration
147
- WHISPER_MODEL = os.getenv("WHISPER_MODEL", "small") # Can use 'base' with 16GB RAM!
148
  DEVICE = os.getenv("DEVICE", "cpu")
149
  USE_FP16 = False
150
 
@@ -328,6 +328,7 @@ async def root():
328
  "endpoints": {
329
  "docs": "/docs",
330
  "health": "/health",
 
331
  "process": "/process (POST)",
332
  "enhance": "/enhance (POST)",
333
  "transcribe": "/transcribe (POST)",
@@ -355,6 +356,27 @@ async def health_check():
355
  "device": Config.DEVICE,
356
  "tts_available": tts_available
357
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
 
359
 
360
  @app.post("/process", response_model=ProcessResponse)
 
144
  CNN_CHECKPOINT = CHECKPOINT_DIR / HF_CHECKPOINT_FILENAME
145
 
146
  # Model configuration
147
+ WHISPER_MODEL = os.getenv("WHISPER_MODEL", "small")
148
  DEVICE = os.getenv("DEVICE", "cpu")
149
  USE_FP16 = False
150
 
 
328
  "endpoints": {
329
  "docs": "/docs",
330
  "health": "/health",
331
+ "warmup": "/warmup",
332
  "process": "/process (POST)",
333
  "enhance": "/enhance (POST)",
334
  "transcribe": "/transcribe (POST)",
 
356
  "device": Config.DEVICE,
357
  "tts_available": tts_available
358
  }
359
+ PING_COUNT = 0
360
+
361
+ @app.get("/warmup")
362
+ @app.post("/warmup")
363
+ async def warmup():
364
+ """
365
+ Lightweight endpoint to simulate activity for keepalive pings.
366
+ Accepts both GET (browser) and POST (curl/action).
367
+ """
368
+ global PING_COUNT
369
+ PING_COUNT += 1
370
+
371
+ # Minimal CPU work to look like real activity
372
+ import numpy as np
373
+ _ = np.zeros((1000,))
374
+
375
+ return {
376
+ "ok": True,
377
+ "message": "Warmup ping received",
378
+ "total_pings": PING_COUNT
379
+ }
380
 
381
 
382
  @app.post("/process", response_model=ProcessResponse)