Samfredoly commited on
Commit
7b55656
·
verified ·
1 Parent(s): e07e2c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -298,11 +298,28 @@ def find_matching_filename(transcribed_filename: str, reference_map: Dict[str, s
298
  log_message(f"⚠️ No matching filename found for: {transcribed_filename}", "WARNING")
299
  return None
300
 
 
 
 
 
 
 
 
 
301
  def transcribe_audio(wav_path: str) -> Optional[Dict[str, Any]]:
302
  """Transcribe audio file using Whisper."""
303
  log_message(f"🎤 Transcribing audio file: {wav_path}", "INFO")
304
 
305
  try:
 
 
 
 
 
 
 
 
 
306
  import whisper
307
 
308
  # Load model
@@ -661,6 +678,20 @@ async def process_single_file(filename: str):
661
  @app.on_event("startup")
662
  async def startup_event():
663
  """Auto-start processing when server starts"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
664
  log_message("🚀 Server startup: Auto-starting processing loop", "INFO")
665
 
666
  # Start processing in a separate thread
 
298
  log_message(f"⚠️ No matching filename found for: {transcribed_filename}", "WARNING")
299
  return None
300
 
301
+ def check_ffmpeg() -> bool:
302
+ """Check if ffmpeg is installed"""
303
+ try:
304
+ subprocess.run(["ffmpeg", "-version"], capture_output=True, check=True)
305
+ return True
306
+ except (FileNotFoundError, subprocess.CalledProcessError):
307
+ return False
308
+
309
  def transcribe_audio(wav_path: str) -> Optional[Dict[str, Any]]:
310
  """Transcribe audio file using Whisper."""
311
  log_message(f"🎤 Transcribing audio file: {wav_path}", "INFO")
312
 
313
  try:
314
+ # Check ffmpeg first
315
+ if not check_ffmpeg():
316
+ log_message("❌ ffmpeg not found. Install with: pip install ffmpeg-python or use system package manager", "ERROR")
317
+ log_message(" Windows (Chocolatey): choco install ffmpeg", "ERROR")
318
+ log_message(" Windows (Scoop): scoop install ffmpeg", "ERROR")
319
+ log_message(" Linux (Ubuntu): sudo apt-get install ffmpeg", "ERROR")
320
+ log_message(" macOS (Homebrew): brew install ffmpeg", "ERROR")
321
+ return None
322
+
323
  import whisper
324
 
325
  # Load model
 
678
  @app.on_event("startup")
679
  async def startup_event():
680
  """Auto-start processing when server starts"""
681
+ log_message("🚀 Server startup: Checking dependencies...", "INFO")
682
+
683
+ # Check ffmpeg
684
+ if not check_ffmpeg():
685
+ log_message("⚠️ WARNING: ffmpeg is not installed!", "WARNING")
686
+ log_message(" Whisper requires ffmpeg for audio processing", "WARNING")
687
+ log_message(" Install with one of the following:", "WARNING")
688
+ log_message(" - Windows (Chocolatey): choco install ffmpeg", "WARNING")
689
+ log_message(" - Windows (Scoop): scoop install ffmpeg", "WARNING")
690
+ log_message(" - Linux (Ubuntu): sudo apt-get install ffmpeg", "WARNING")
691
+ log_message(" - macOS (Homebrew): brew install ffmpeg", "WARNING")
692
+ else:
693
+ log_message("✅ ffmpeg found", "INFO")
694
+
695
  log_message("🚀 Server startup: Auto-starting processing loop", "INFO")
696
 
697
  # Start processing in a separate thread