VeuReu commited on
Commit
2c4c220
verified
1 Parent(s): f050d10

Upload 2 files

Browse files
data/db/audiodescriptions.db CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3fa92deb21efe3d3a1fcde75957015f2ef49805b98a3190d1210d5a4df11732e
3
- size 241664
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a13210efd35fac936ea87d238e323cdfe3e02c7a707310168106aaaed46c798
3
+ size 278528
page_modules/analyze_audiodescriptions.py CHANGED
@@ -244,18 +244,37 @@ def render_analyze_audiodescriptions_page(api, permissions: Dict[str, bool]) ->
244
  key="version_selector",
245
  )
246
 
247
- # Cargar valores de evaluaci贸n cuando cambia la versi贸n
248
  if subcarpeta_seleccio:
249
  ensure_media_for_video(base_dir, api, selected_sha1, subcarpeta_seleccio)
250
 
251
- # Clau 煤nica per v铆deo (sha1) + versi贸 seleccionada
252
- current_version_key = f"{selected_sha1}_{subcarpeta_seleccio}"
 
 
 
 
253
  if "last_version_key" not in st.session_state or st.session_state.last_version_key != current_version_key:
254
  st.session_state.last_version_key = current_version_key
255
 
256
- # Intentar llegir eval des de audiodescriptions.db
257
  ad_row = get_audiodescription(selected_sha1, subcarpeta_seleccio)
258
- eval_text = ad_row["eval"] if ad_row is not None and "eval" in ad_row.keys() else None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
 
260
  eval_values = load_eval_values(vid_dir, subcarpeta_seleccio, eval_text)
261
  if eval_values:
@@ -518,30 +537,24 @@ def render_analyze_audiodescriptions_page(api, permissions: Dict[str, bool]) ->
518
  if not srt_text.strip():
519
  st.warning("No hi ha cap text UNE disponible per descarregar en aquesta versi贸.")
520
  else:
521
- try:
522
- response = api.generate_une_ad_audio_from_srt(srt_text, voice="central/grau")
523
- except Exception as e:
524
- st.error(f"Error cridant el servei TTS: {e}")
525
- response = {"error": str(e)}
 
526
 
527
  if "mp3_bytes" not in response:
528
  st.error(f"Error en la generaci贸 de l'脿udio: {response.get('error', 'Desconegut')}")
529
  else:
530
  mp3_bytes = response["mp3_bytes"]
531
- srt_bytes = srt_text.encode("utf-8", errors="ignore")
532
 
533
  st.download_button(
534
- "Descarregar MP3 d'audiodescripci贸",
535
  data=mp3_bytes,
536
  file_name=f"{selected_sha1}_{subcarpeta_seleccio}_une_ad.mp3",
537
  mime="audio/mpeg",
538
- )
539
-
540
- st.download_button(
541
- "Descarregar SRT d'audiodescripci贸",
542
- data=srt_bytes,
543
- file_name=f"{selected_sha1}_{subcarpeta_seleccio}_une_ad.srt",
544
- mime="application/x-subrip",
545
  )
546
 
547
  with col_txt:
 
244
  key="version_selector",
245
  )
246
 
247
+ # Cargar valores de evaluaci贸n cuando cambian v铆deo, versi贸 o opci贸 d'historial
248
  if subcarpeta_seleccio:
249
  ensure_media_for_video(base_dir, api, selected_sha1, subcarpeta_seleccio)
250
 
251
+ # Historial seleccionat actualment (Original / HITL OK / HITL Test)
252
+ hist_key_suffix = f"{selected_sha1}_{subcarpeta_seleccio or 'none'}"
253
+ hist_choice_for_eval = st.session_state.get(f"ad_hist_choice_{hist_key_suffix}", "HITL OK")
254
+
255
+ # Clau 煤nica per v铆deo (sha1) + versi贸 seleccionada + opci贸 d'historial
256
+ current_version_key = f"{selected_sha1}_{subcarpeta_seleccio}_{hist_choice_for_eval}"
257
  if "last_version_key" not in st.session_state or st.session_state.last_version_key != current_version_key:
258
  st.session_state.last_version_key = current_version_key
259
 
260
+ # Seleccionar el camp d'avaluaci贸 segons l'opci贸 d'historial
261
  ad_row = get_audiodescription(selected_sha1, subcarpeta_seleccio)
262
+ eval_text = None
263
+ if ad_row is not None:
264
+ cols = set(ad_row.keys())
265
+ if hist_choice_for_eval == "Original":
266
+ if "eval" in cols:
267
+ eval_text = ad_row["eval"]
268
+ elif hist_choice_for_eval == "HITL OK":
269
+ if "ok_eval" in cols and ad_row["ok_eval"]:
270
+ eval_text = ad_row["ok_eval"]
271
+ elif "eval" in cols:
272
+ eval_text = ad_row["eval"]
273
+ else: # "HITL Test"
274
+ if "test_eval" in cols and ad_row["test_eval"]:
275
+ eval_text = ad_row["test_eval"]
276
+ elif "eval" in cols:
277
+ eval_text = ad_row["eval"]
278
 
279
  eval_values = load_eval_values(vid_dir, subcarpeta_seleccio, eval_text)
280
  if eval_values:
 
537
  if not srt_text.strip():
538
  st.warning("No hi ha cap text UNE disponible per descarregar en aquesta versi贸.")
539
  else:
540
+ with st.spinner("Generant AD mp3..."):
541
+ try:
542
+ response = api.generate_une_ad_audio_from_srt(srt_text, voice="central/grau")
543
+ except Exception as e:
544
+ st.error(f"Error cridant el servei TTS: {e}")
545
+ response = {"error": str(e)}
546
 
547
  if "mp3_bytes" not in response:
548
  st.error(f"Error en la generaci贸 de l'脿udio: {response.get('error', 'Desconegut')}")
549
  else:
550
  mp3_bytes = response["mp3_bytes"]
 
551
 
552
  st.download_button(
553
+ "Descarregar pista d'audiodescripci贸",
554
  data=mp3_bytes,
555
  file_name=f"{selected_sha1}_{subcarpeta_seleccio}_une_ad.mp3",
556
  mime="audio/mpeg",
557
+ key="download_ad_track_mp3_only",
 
 
 
 
 
 
558
  )
559
 
560
  with col_txt: