AiAnber commited on
Commit
e967da2
·
verified ·
1 Parent(s): e99b91c

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +5 -3
src/streamlit_app.py CHANGED
@@ -49,8 +49,10 @@ st.markdown("""
49
  st.markdown('<div class="card"><span class="big-font">Speech Threat Detection Dashboard</span> <span class="muted"> — upload audio or paste text </span></div>', unsafe_allow_html=True)
50
 
51
  UPLOAD_DIR = Path("/tmp/uploads")
 
 
52
  DB_CSV = Path("/tmp/db.csv")
53
- UPLOAD_DIR.mkdir(exist_ok=True)
54
  if not DB_CSV.exists():
55
  pd.DataFrame(columns=["timestamp","filename","mode","transcription","predicted_label","scores"]).to_csv(DB_CSV, index=False)
56
 
@@ -84,10 +86,10 @@ def save_audio_file(uploaded_file) -> Path:
84
  def normalize_audio_to_wav(path: Path) -> Path:
85
  sound = AudioSegment.from_file(path)
86
  sound = sound.set_frame_rate(16000).set_channels(1).set_sample_width(2)
87
- wav_path = path.with_suffix(".wav")
 
88
  sound.export(wav_path, format="wav")
89
  return wav_path
90
-
91
  @st.cache_resource(show_spinner=False)
92
  def get_asr_pipeline() -> Tuple[str, "Pipeline"]:
93
  """Load Hugging Face Whisper ASR model"""
 
49
  st.markdown('<div class="card"><span class="big-font">Speech Threat Detection Dashboard</span> <span class="muted"> — upload audio or paste text </span></div>', unsafe_allow_html=True)
50
 
51
  UPLOAD_DIR = Path("/tmp/uploads")
52
+ UPLOAD_DIR.mkdir(parents=True, exist_ok=True)
53
+
54
  DB_CSV = Path("/tmp/db.csv")
55
+
56
  if not DB_CSV.exists():
57
  pd.DataFrame(columns=["timestamp","filename","mode","transcription","predicted_label","scores"]).to_csv(DB_CSV, index=False)
58
 
 
86
  def normalize_audio_to_wav(path: Path) -> Path:
87
  sound = AudioSegment.from_file(path)
88
  sound = sound.set_frame_rate(16000).set_channels(1).set_sample_width(2)
89
+ #wav_path = path.with_suffix(".wav")
90
+ wav_path = UPLOAD_DIR / f"{path.stem}.wav"
91
  sound.export(wav_path, format="wav")
92
  return wav_path
 
93
  @st.cache_resource(show_spinner=False)
94
  def get_asr_pipeline() -> Tuple[str, "Pipeline"]:
95
  """Load Hugging Face Whisper ASR model"""