Marek4321 commited on
Commit
a451ea6
·
verified ·
1 Parent(s): 038b4c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -21
app.py CHANGED
@@ -222,7 +222,7 @@ class FGIIDIAnalyzer:
222
  )
223
 
224
  if uploaded_files:
225
- # Walidacja plików
226
  valid_files = []
227
  total_size = 0
228
 
@@ -230,23 +230,27 @@ class FGIIDIAnalyzer:
230
  file_size_mb = file.size / (1024 * 1024)
231
  total_size += file_size_mb
232
 
233
- # Sprawdź rozmiar pojedynczego pliku
234
- if file_size_mb > 100: # 100MB limit dla pojedynczego pliku
235
- st.error(f"❌ {file.name}: Plik za duży ({file_size_mb:.1f}MB). Maksymalnie 100MB.")
 
 
236
  continue
237
 
238
- valid_files.append({
239
- 'file': file,
240
- 'name': file.name,
241
- 'size_mb': file_size_mb,
242
- 'needs_splitting': file_size_mb > settings['max_file_size'],
243
- 'needs_compression': file_size_mb > 25 # Whisper limit
244
- })
245
 
246
  # Wyświetl informacje o plikach
247
  if valid_files:
248
  st.success(f"✅ Załadowano {len(valid_files)} plików ({total_size:.1f}MB)")
249
 
 
 
 
 
 
250
  # Tabela z informacjami o plikach
251
  for i, file_info in enumerate(valid_files):
252
  col1, col2, col3 = st.columns([3, 1, 1])
@@ -258,10 +262,12 @@ class FGIIDIAnalyzer:
258
  st.write(f"{file_info['size_mb']:.1f}MB")
259
 
260
  with col3:
261
- if file_info['needs_compression']:
262
- st.error("Wymaga kompresji")
263
  elif file_info['needs_splitting']:
264
- st.warning("Będzie podzielony")
 
 
265
  else:
266
  st.success("OK")
267
 
@@ -389,18 +395,22 @@ class FGIIDIAnalyzer:
389
  if not processed_files:
390
  raise Exception("Nie udało się przetworzyć pliku")
391
 
392
- # Sprawdź rozmiary przed wysłaniem do Whisper
 
393
  for pf in processed_files:
394
  file_size_mb = os.path.getsize(pf) / (1024 * 1024)
395
  if file_size_mb > 25:
396
- self.log_message(f" Część {pf} za duża dla Whisper: {file_size_mb:.1f}MB", "ERROR")
397
- continue
 
 
 
 
398
 
399
  # Transkrypcja z retry logic
400
- transcription = self.transcriber.transcribe_with_retries(
401
- processed_files[0] if len(processed_files) == 1 else processed_files,
402
- language=settings['language'],
403
- max_retries=3
404
  )
405
 
406
  if transcription:
 
222
  )
223
 
224
  if uploaded_files:
225
+ # Walidacja plików z nową metodą
226
  valid_files = []
227
  total_size = 0
228
 
 
230
  file_size_mb = file.size / (1024 * 1024)
231
  total_size += file_size_mb
232
 
233
+ # Użyj nowej walidacji dla Whisper
234
+ is_valid, message = self.file_handler.validate_file_for_whisper(file)
235
+
236
+ if not is_valid:
237
+ st.error(f"❌ {file.name}: {message}")
238
  continue
239
 
240
+ # Pobierz szczegółowe info o pliku
241
+ file_info = self.file_handler.get_file_info(file)
242
+ file_info['file'] = file # Dodaj obiekt pliku
243
+ valid_files.append(file_info)
 
 
 
244
 
245
  # Wyświetl informacje o plikach
246
  if valid_files:
247
  st.success(f"✅ Załadowano {len(valid_files)} plików ({total_size:.1f}MB)")
248
 
249
+ # Pokaż plan przetwarzania
250
+ if any(not f['whisper_ready'] for f in valid_files):
251
+ plan = self.file_handler.create_processing_plan([f['file'] for f in valid_files])
252
+ st.info(plan)
253
+
254
  # Tabela z informacjami o plikach
255
  for i, file_info in enumerate(valid_files):
256
  col1, col2, col3 = st.columns([3, 1, 1])
 
262
  st.write(f"{file_info['size_mb']:.1f}MB")
263
 
264
  with col3:
265
+ if file_info['too_large']:
266
+ st.error("Za duży")
267
  elif file_info['needs_splitting']:
268
+ st.warning("Podział")
269
+ elif file_info['needs_compression']:
270
+ st.warning("Kompresja")
271
  else:
272
  st.success("OK")
273
 
 
395
  if not processed_files:
396
  raise Exception("Nie udało się przetworzyć pliku")
397
 
398
+ # Walidacja rozmiaru wszystkich części
399
+ valid_parts = []
400
  for pf in processed_files:
401
  file_size_mb = os.path.getsize(pf) / (1024 * 1024)
402
  if file_size_mb > 25:
403
+ self.log_message(f"⚠️ Część {pf} za duża: {file_size_mb:.1f}MB", "WARNING")
404
+ else:
405
+ valid_parts.append(pf)
406
+
407
+ if not valid_parts:
408
+ raise Exception("Wszystkie części za duże dla Whisper API")
409
 
410
  # Transkrypcja z retry logic
411
+ transcription = self.transcriber.transcribe_files(
412
+ valid_parts,
413
+ language=settings['language']
 
414
  )
415
 
416
  if transcription: