habulaj commited on
Commit
b9780fc
·
verified ·
1 Parent(s): 499e3a5

Update utils/helpers.py

Browse files
Files changed (1) hide show
  1. utils/helpers.py +11 -1
utils/helpers.py CHANGED
@@ -66,7 +66,17 @@ def clean_and_validate_srt(srt_content):
66
  srt_corrigido = ""
67
  for i, (num, start, end, text) in enumerate(matches, 1):
68
  text = text.strip()
69
- if not text: continue
 
 
 
 
 
 
 
 
 
 
70
  text_lines = [line.strip() for line in text.split('\n') if line.strip()]
71
  if len(text_lines) > 2:
72
  text = text_lines[0] + '\n' + ' '.join(text_lines[1:])
 
66
  srt_corrigido = ""
67
  for i, (num, start, end, text) in enumerate(matches, 1):
68
  text = text.strip()
69
+ # NÃO pule blocos de texto vazio — o prompt de tradução
70
+ # (build_subtitle_translation_prompt) instrui explicitamente o
71
+ # Gemini a deixar um bloco em branco quando não há fala real
72
+ # (silêncio, ruído, alucinação do Whisper), mas MANTER o bloco em
73
+ # si (número + timestamp), justamente pra preservar a contagem
74
+ # exata de blocos que translate_srt_with_gemini valida logo depois.
75
+ # Descartar aqui um bloco que o próprio Gemini devolveu vazio (de
76
+ # propósito, seguindo a instrução) fazia a contagem NUNCA bater —
77
+ # toda tradução com pelo menos um trecho mudo falhava as 3
78
+ # tentativas e derrubava o pedido inteiro (visto tanto no
79
+ # /editor/create-project novo quanto no /subtitle já existente).
80
  text_lines = [line.strip() for line in text.split('\n') if line.strip()]
81
  if len(text_lines) > 2:
82
  text = text_lines[0] + '\n' + ' '.join(text_lines[1:])