Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,14 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import sys
|
| 3 |
import os
|
| 4 |
from datetime import datetime
|
|
@@ -7,28 +17,37 @@ import traceback
|
|
| 7 |
import threading
|
| 8 |
import queue
|
| 9 |
|
| 10 |
-
# Sprawdzenie zależności
|
| 11 |
try:
|
| 12 |
import openai
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
except ImportError as e:
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
st.info("HuggingFace is installing dependencies... Refresh page in 30 seconds.")
|
| 17 |
st.stop()
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
from file_handler import FileHandler
|
| 23 |
-
from config import NVIDIA_THEME, DEFAULT_SETTINGS
|
| 24 |
-
|
| 25 |
-
# Konfiguracja strony
|
| 26 |
-
st.set_page_config(
|
| 27 |
-
page_title="QualiInsightLab",
|
| 28 |
-
page_icon="🎙️",
|
| 29 |
-
layout="wide",
|
| 30 |
-
initial_sidebar_state="expanded"
|
| 31 |
-
)
|
| 32 |
|
| 33 |
# Custom CSS - kolorystyka NVIDIA
|
| 34 |
st.markdown(f"""
|
|
@@ -128,6 +147,66 @@ class FGIIDIAnalyzer:
|
|
| 128 |
print(f"LOG ERROR: {log_entry}")
|
| 129 |
print(f"LOG ERROR DETAILS: {e}")
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
def render_sidebar(self):
|
| 132 |
"""Renderuj sidebar z konfiguracją"""
|
| 133 |
st.sidebar.title("🎙️ QualiInsightLab")
|
|
@@ -200,57 +279,6 @@ class FGIIDIAnalyzer:
|
|
| 200 |
'language': language
|
| 201 |
}
|
| 202 |
|
| 203 |
-
def update_progress_safe(self, progress_value, status_message):
|
| 204 |
-
"""Thread-safe aktualizacja postępu"""
|
| 205 |
-
try:
|
| 206 |
-
st.session_state.overall_progress = progress_value
|
| 207 |
-
st.session_state.current_file_progress = status_message
|
| 208 |
-
except:
|
| 209 |
-
# Fallback - wyświetl w konsoli
|
| 210 |
-
print(f"PROGRESS: {progress_value:.1%} - {status_message}")
|
| 211 |
-
|
| 212 |
-
def update_transcriptions_safe(self, filename, transcription):
|
| 213 |
-
"""Thread-safe aktualizacja transkrypcji"""
|
| 214 |
-
try:
|
| 215 |
-
st.session_state.transcriptions[filename] = transcription
|
| 216 |
-
except:
|
| 217 |
-
# Fallback - zapisz do lokalnej zmiennej
|
| 218 |
-
if not hasattr(self, 'local_transcriptions'):
|
| 219 |
-
self.local_transcriptions = {}
|
| 220 |
-
self.local_transcriptions[filename] = transcription
|
| 221 |
-
print(f"TRANSCRIPTION: {filename} completed locally")
|
| 222 |
-
|
| 223 |
-
def sync_local_data(self):
|
| 224 |
-
"""Synchronizuj dane lokalne z session_state"""
|
| 225 |
-
try:
|
| 226 |
-
# Przenies logi lokalne do session_state
|
| 227 |
-
if hasattr(self, 'local_logs'):
|
| 228 |
-
for log in self.local_logs:
|
| 229 |
-
st.session_state.logs.append(log)
|
| 230 |
-
self.local_logs = []
|
| 231 |
-
|
| 232 |
-
# Przenies transkrypcje lokalne do session_state
|
| 233 |
-
if hasattr(self, 'local_transcriptions'):
|
| 234 |
-
for filename, transcription in self.local_transcriptions.items():
|
| 235 |
-
st.session_state.transcriptions[filename] = transcription
|
| 236 |
-
self.local_transcriptions = {}
|
| 237 |
-
|
| 238 |
-
except Exception as e:
|
| 239 |
-
print(f"SYNC ERROR: {e}")
|
| 240 |
-
"""Wyczyść sesję i pliki tymczasowe"""
|
| 241 |
-
# Zatrzymaj przetwarzanie jeśli trwa
|
| 242 |
-
if st.session_state.processing_status == 'running':
|
| 243 |
-
st.session_state.processing_status = 'stopped'
|
| 244 |
-
|
| 245 |
-
# Wyczyść pliki tymczasowe
|
| 246 |
-
self.file_handler.cleanup_temp_files()
|
| 247 |
-
|
| 248 |
-
# Wyczyść session state
|
| 249 |
-
for key in list(st.session_state.keys()):
|
| 250 |
-
del st.session_state[key]
|
| 251 |
-
|
| 252 |
-
self.initialize_session_state()
|
| 253 |
-
|
| 254 |
def render_file_upload(self, settings):
|
| 255 |
"""Renderuj sekcję upload plików"""
|
| 256 |
st.header("📁 Upload plików audio/video")
|
|
@@ -547,31 +575,6 @@ class FGIIDIAnalyzer:
|
|
| 547 |
except:
|
| 548 |
print(f"CRITICAL ERROR: {e}")
|
| 549 |
|
| 550 |
-
def sync_local_data(self):
|
| 551 |
-
"""Synchronizuj dane lokalne z session_state"""
|
| 552 |
-
try:
|
| 553 |
-
# Przenies logi lokalne do session_state
|
| 554 |
-
if hasattr(self, 'local_logs'):
|
| 555 |
-
for log in self.local_logs:
|
| 556 |
-
if 'logs' in st.session_state:
|
| 557 |
-
st.session_state.logs.append(log)
|
| 558 |
-
self.local_logs = []
|
| 559 |
-
|
| 560 |
-
# Przenies transkrypcje lokalne do session_state
|
| 561 |
-
if hasattr(self, 'local_transcriptions'):
|
| 562 |
-
for filename, transcription in self.local_transcriptions.items():
|
| 563 |
-
st.session_state.transcriptions[filename] = transcription
|
| 564 |
-
self.local_transcriptions = {}
|
| 565 |
-
|
| 566 |
-
# Przenies raport lokalny do session_state
|
| 567 |
-
if hasattr(self, 'local_final_report'):
|
| 568 |
-
st.session_state.final_report = self.local_final_report
|
| 569 |
-
st.session_state.processing_status = 'completed'
|
| 570 |
-
delattr(self, 'local_final_report')
|
| 571 |
-
|
| 572 |
-
except Exception as e:
|
| 573 |
-
print(f"SYNC ERROR: {e}")
|
| 574 |
-
|
| 575 |
def render_results(self):
|
| 576 |
"""Renderuj wyniki"""
|
| 577 |
if not st.session_state.transcriptions and not st.session_state.final_report:
|
|
@@ -690,4 +693,4 @@ if __name__ == "__main__":
|
|
| 690 |
|
| 691 |
# Emergency restart
|
| 692 |
if st.button("🚨 Awaryjny restart"):
|
| 693 |
-
st.
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# UWAGA: st.set_page_config() MUSI być pierwszą komendą Streamlit!
|
| 4 |
+
st.set_page_config(
|
| 5 |
+
page_title="QualiInsightLab",
|
| 6 |
+
page_icon="🎙️",
|
| 7 |
+
layout="wide",
|
| 8 |
+
initial_sidebar_state="expanded"
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
# Teraz importy i reszta kodu
|
| 12 |
import sys
|
| 13 |
import os
|
| 14 |
from datetime import datetime
|
|
|
|
| 17 |
import threading
|
| 18 |
import queue
|
| 19 |
|
| 20 |
+
# Sprawdzenie zależności BEZ używania st.success/st.error przed set_page_config
|
| 21 |
try:
|
| 22 |
import openai
|
| 23 |
+
OPENAI_AVAILABLE = True
|
| 24 |
+
openai_status = "✅ OpenAI library loaded successfully"
|
| 25 |
+
except ImportError as e:
|
| 26 |
+
OPENAI_AVAILABLE = False
|
| 27 |
+
openai_status = f"❌ OpenAI library missing: {e}"
|
| 28 |
+
|
| 29 |
+
# Import modułów (bez używania Streamlit commands)
|
| 30 |
+
try:
|
| 31 |
+
from transcription import AudioTranscriber
|
| 32 |
+
from report_generator import ReportGenerator
|
| 33 |
+
from file_handler import FileHandler
|
| 34 |
+
from config import NVIDIA_THEME, DEFAULT_SETTINGS
|
| 35 |
+
modules_loaded = True
|
| 36 |
except ImportError as e:
|
| 37 |
+
modules_loaded = False
|
| 38 |
+
import_error = str(e)
|
| 39 |
+
|
| 40 |
+
# Teraz możemy użyć komend Streamlit
|
| 41 |
+
if OPENAI_AVAILABLE:
|
| 42 |
+
st.success(openai_status)
|
| 43 |
+
else:
|
| 44 |
+
st.error(openai_status)
|
| 45 |
st.info("HuggingFace is installing dependencies... Refresh page in 30 seconds.")
|
| 46 |
st.stop()
|
| 47 |
|
| 48 |
+
if not modules_loaded:
|
| 49 |
+
st.error(f"❌ Błąd importu modułów: {import_error}")
|
| 50 |
+
st.stop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# Custom CSS - kolorystyka NVIDIA
|
| 53 |
st.markdown(f"""
|
|
|
|
| 147 |
print(f"LOG ERROR: {log_entry}")
|
| 148 |
print(f"LOG ERROR DETAILS: {e}")
|
| 149 |
|
| 150 |
+
def update_progress_safe(self, progress_value, status_message):
|
| 151 |
+
"""Thread-safe aktualizacja postępu"""
|
| 152 |
+
try:
|
| 153 |
+
st.session_state.overall_progress = progress_value
|
| 154 |
+
st.session_state.current_file_progress = status_message
|
| 155 |
+
except:
|
| 156 |
+
# Fallback - wyświetl w konsoli
|
| 157 |
+
print(f"PROGRESS: {progress_value:.1%} - {status_message}")
|
| 158 |
+
|
| 159 |
+
def update_transcriptions_safe(self, filename, transcription):
|
| 160 |
+
"""Thread-safe aktualizacja transkrypcji"""
|
| 161 |
+
try:
|
| 162 |
+
st.session_state.transcriptions[filename] = transcription
|
| 163 |
+
except:
|
| 164 |
+
# Fallback - zapisz do lokalnej zmiennej
|
| 165 |
+
if not hasattr(self, 'local_transcriptions'):
|
| 166 |
+
self.local_transcriptions = {}
|
| 167 |
+
self.local_transcriptions[filename] = transcription
|
| 168 |
+
print(f"TRANSCRIPTION: {filename} completed locally")
|
| 169 |
+
|
| 170 |
+
def sync_local_data(self):
|
| 171 |
+
"""Synchronizuj dane lokalne z session_state"""
|
| 172 |
+
try:
|
| 173 |
+
# Przenies logi lokalne do session_state
|
| 174 |
+
if hasattr(self, 'local_logs'):
|
| 175 |
+
for log in self.local_logs:
|
| 176 |
+
if 'logs' in st.session_state:
|
| 177 |
+
st.session_state.logs.append(log)
|
| 178 |
+
self.local_logs = []
|
| 179 |
+
|
| 180 |
+
# Przenies transkrypcje lokalne do session_state
|
| 181 |
+
if hasattr(self, 'local_transcriptions'):
|
| 182 |
+
for filename, transcription in self.local_transcriptions.items():
|
| 183 |
+
st.session_state.transcriptions[filename] = transcription
|
| 184 |
+
self.local_transcriptions = {}
|
| 185 |
+
|
| 186 |
+
# Przenies raport lokalny do session_state
|
| 187 |
+
if hasattr(self, 'local_final_report'):
|
| 188 |
+
st.session_state.final_report = self.local_final_report
|
| 189 |
+
st.session_state.processing_status = 'completed'
|
| 190 |
+
delattr(self, 'local_final_report')
|
| 191 |
+
|
| 192 |
+
except Exception as e:
|
| 193 |
+
print(f"SYNC ERROR: {e}")
|
| 194 |
+
|
| 195 |
+
def cleanup_session(self):
|
| 196 |
+
"""Wyczyść sesję i pliki tymczasowe"""
|
| 197 |
+
# Zatrzymaj przetwarzanie jeśli trwa
|
| 198 |
+
if st.session_state.processing_status == 'running':
|
| 199 |
+
st.session_state.processing_status = 'stopped'
|
| 200 |
+
|
| 201 |
+
# Wyczyść pliki tymczasowe
|
| 202 |
+
self.file_handler.cleanup_temp_files()
|
| 203 |
+
|
| 204 |
+
# Wyczyść session state
|
| 205 |
+
for key in list(st.session_state.keys()):
|
| 206 |
+
del st.session_state[key]
|
| 207 |
+
|
| 208 |
+
self.initialize_session_state()
|
| 209 |
+
|
| 210 |
def render_sidebar(self):
|
| 211 |
"""Renderuj sidebar z konfiguracją"""
|
| 212 |
st.sidebar.title("🎙️ QualiInsightLab")
|
|
|
|
| 279 |
'language': language
|
| 280 |
}
|
| 281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
def render_file_upload(self, settings):
|
| 283 |
"""Renderuj sekcję upload plików"""
|
| 284 |
st.header("📁 Upload plików audio/video")
|
|
|
|
| 575 |
except:
|
| 576 |
print(f"CRITICAL ERROR: {e}")
|
| 577 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 578 |
def render_results(self):
|
| 579 |
"""Renderuj wyniki"""
|
| 580 |
if not st.session_state.transcriptions and not st.session_state.final_report:
|
|
|
|
| 693 |
|
| 694 |
# Emergency restart
|
| 695 |
if st.button("🚨 Awaryjny restart"):
|
| 696 |
+
st.rerun()
|