RaiSantos commited on
Commit
b6fad38
·
verified ·
1 Parent(s): 6868cd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -21
app.py CHANGED
@@ -103,24 +103,13 @@ def inicializar_modelos(modelo_selecionado, progress=gr.Progress()):
103
  # Carregar WhisperX otimizado para HF
104
  if modelo_selecionado not in whisper_models:
105
  try:
106
- # Configurações otimizadas para não perder palavras
107
  asr_options = {
108
  "beam_size": config["beam_size"],
109
  "best_of": config["best_of"],
110
  "temperature": config["temperature"],
111
- "condition_on_previous_text": True,
112
  "word_timestamps": True,
113
- "prepend_punctuations": "\"'([{-",
114
- "append_punctuations": "\"'.,:!?)]}-",
115
- "vad_filter": True,
116
- "vad_parameters": {
117
- "min_silence_duration_ms": 300, # Reduzido para capturar mais
118
- "speech_pad_ms": 400,
119
- "max_speech_duration_s": float('inf')
120
- },
121
- "no_speech_threshold": 0.4, # Reduzido para capturar mais fala
122
- "logprob_threshold": -0.8, # Menos restritivo
123
- "compression_ratio_threshold": 2.2
124
  }
125
 
126
  whisper_models[modelo_selecionado] = whisperx.load_model(
@@ -138,7 +127,7 @@ def inicializar_modelos(modelo_selecionado, progress=gr.Progress()):
138
 
139
  except Exception as model_error:
140
  print(f"Erro no modelo principal: {model_error}")
141
- # Fallback básico
142
  whisper_models[modelo_selecionado] = whisperx.load_model(
143
  modelo_selecionado,
144
  device,
@@ -263,16 +252,12 @@ def processar_audio_vsl(audio_file, modelo_selecionado, progress=gr.Progress()):
263
 
264
  progress(0.2, desc=f"🎤 Transcrevendo com {config['display_name']}...")
265
 
266
- # Transcrição com configurações para não perder palavras
267
  result = whisper_models[modelo_selecionado].transcribe(
268
  audio,
269
  batch_size=config["batch_size"],
270
- chunk_size=config["chunk_size"],
271
- condition_on_previous_text=True,
272
  language=LANGUAGE,
273
- word_timestamps=True,
274
- prepend_punctuations="\"'([{-",
275
- append_punctuations="\"'.,:!?)]}-"
276
  )
277
 
278
  progress(0.5, desc="🎯 Alinhamento temporal de alta precisão...")
@@ -447,7 +432,11 @@ def criar_interface_hf():
447
  border: 2px solid #10b981;
448
  border-radius: 8px;
449
  padding: 16px;
450
- background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
 
 
 
 
451
  }
452
  """
453
  ) as demo:
 
103
  # Carregar WhisperX otimizado para HF
104
  if modelo_selecionado not in whisper_models:
105
  try:
106
+ # Configurações otimizadas para não perder palavras (SIMPLIFICADAS)
107
  asr_options = {
108
  "beam_size": config["beam_size"],
109
  "best_of": config["best_of"],
110
  "temperature": config["temperature"],
 
111
  "word_timestamps": True,
112
+ "vad_filter": True
 
 
 
 
 
 
 
 
 
 
113
  }
114
 
115
  whisper_models[modelo_selecionado] = whisperx.load_model(
 
127
 
128
  except Exception as model_error:
129
  print(f"Erro no modelo principal: {model_error}")
130
+ # Fallback com configurações mínimas
131
  whisper_models[modelo_selecionado] = whisperx.load_model(
132
  modelo_selecionado,
133
  device,
 
252
 
253
  progress(0.2, desc=f"🎤 Transcrevendo com {config['display_name']}...")
254
 
255
+ # Transcrição com configurações para não perder palavras (CORRIGIDA)
256
  result = whisper_models[modelo_selecionado].transcribe(
257
  audio,
258
  batch_size=config["batch_size"],
 
 
259
  language=LANGUAGE,
260
+ word_timestamps=True
 
 
261
  )
262
 
263
  progress(0.5, desc="🎯 Alinhamento temporal de alta precisão...")
 
432
  border: 2px solid #10b981;
433
  border-radius: 8px;
434
  padding: 16px;
435
+ background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
436
+ color: #065f46 !important;
437
+ }
438
+ .status-box * {
439
+ color: #065f46 !important;
440
  }
441
  """
442
  ) as demo: