greg0rs commited on
Commit
a65930b
·
verified ·
1 Parent(s): 8209e58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -473,10 +473,9 @@ def detect_phoneme_from_audio(audio_segment: torch.Tensor, sample_rate: int, wor
473
  log(f"🔧 Padding audio from {audio_segment.shape[-1]} to {target_length} samples")
474
  audio_segment = torch.nn.functional.pad(audio_segment, (0, target_length - audio_segment.shape[-1]))
475
  elif audio_segment.shape[-1] > target_length:
476
- # Take the middle portion to avoid edge effects
477
- start_idx = (audio_segment.shape[-1] - target_length) // 2
478
- log(f"✂️ Truncating audio from {audio_segment.shape[-1]} to {target_length} samples (middle section)")
479
- audio_segment = audio_segment[:, start_idx:start_idx + target_length]
480
  else:
481
  log(f"✅ Audio segment already correct length: {target_length} samples")
482
 
 
473
  log(f"🔧 Padding audio from {audio_segment.shape[-1]} to {target_length} samples")
474
  audio_segment = torch.nn.functional.pad(audio_segment, (0, target_length - audio_segment.shape[-1]))
475
  elif audio_segment.shape[-1] > target_length:
476
+ # Don't truncate long segments - keep full audio for complex words
477
+ log(f"⚠️ Audio longer than target ({audio_segment.shape[-1]} > {target_length}), keeping full length")
478
+ log(f" This preserves all phonemes for long words like 'sophisticated'")
 
479
  else:
480
  log(f"✅ Audio segment already correct length: {target_length} samples")
481