NickVerri commited on
Commit
da08a71
·
verified ·
1 Parent(s): 73ba599

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -10,6 +10,7 @@ import pandas as pd
10
  from datetime import timedelta
11
 
12
  # --- Configuration & Tokens ---
 
13
  HARDCODED_HF_TOKEN = "PASTE_YOUR_HF_TOKEN_HERE"
14
  HARDCODED_GEMINI_KEY = ""
15
 
@@ -127,7 +128,8 @@ if uploaded_file:
127
  device = "cuda" if torch.cuda.is_available() else "cpu"
128
  st.write(f"🚀 **Loading WhisperX on {device}...**")
129
 
130
- # 1. Transcribe
 
131
  # Use float16 for GPU, int8 for CPU
132
  compute_type = "float16" if device == "cuda" else "int8"
133
 
@@ -135,14 +137,14 @@ if uploaded_file:
135
 
136
  st.write("📝 **Transcribing...**")
137
  audio = whisperx.load_audio("temp_audio.wav")
138
- result = model.transcribe(audio, batch_size=16)
139
 
140
  # Cleanup VRAM
141
  gc.collect()
142
  torch.cuda.empty_cache()
143
  del model
144
 
145
- # 2. Align
146
  st.write("⏱️ **Aligning Audio...**")
147
  model_a, metadata = whisperx.load_align_model(language_code=result["language"], device=device)
148
  result = whisperx.align(result["segments"], model_a, metadata, audio, device, return_char_alignments=False)
 
10
  from datetime import timedelta
11
 
12
  # --- Configuration & Tokens ---
13
+ # Priority: Secret > Hardcoded
14
  HARDCODED_HF_TOKEN = "PASTE_YOUR_HF_TOKEN_HERE"
15
  HARDCODED_GEMINI_KEY = ""
16
 
 
128
  device = "cuda" if torch.cuda.is_available() else "cpu"
129
  st.write(f"🚀 **Loading WhisperX on {device}...**")
130
 
131
+ # 1. Transcribe with WhisperX (Faster-Whisper)
132
+ batch_size = 16 # Reduce if low VRAM
133
  # Use float16 for GPU, int8 for CPU
134
  compute_type = "float16" if device == "cuda" else "int8"
135
 
 
137
 
138
  st.write("📝 **Transcribing...**")
139
  audio = whisperx.load_audio("temp_audio.wav")
140
+ result = model.transcribe(audio, batch_size=batch_size)
141
 
142
  # Cleanup VRAM
143
  gc.collect()
144
  torch.cuda.empty_cache()
145
  del model
146
 
147
+ # 2. Align (Improves timestamp accuracy)
148
  st.write("⏱️ **Aligning Audio...**")
149
  model_a, metadata = whisperx.load_align_model(language_code=result["language"], device=device)
150
  result = whisperx.align(result["segments"], model_a, metadata, audio, device, return_char_alignments=False)