Clearwave48 commited on
Commit
a960e11
·
verified ·
1 Parent(s): aff15cd

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -1
main.py CHANGED
@@ -68,6 +68,7 @@ def run_pipeline(audio_path, src_lang="auto", tgt_lang="te",
68
  if (opt_fillers or opt_stutters) and word_segs:
69
  yield {"status": "processing", "step": 3, "message": "Step 3/5 — Removing fillers & stutters..."}
70
  import soundfile as sf
 
71
  audio_data, sr = sf.read(clean1)
72
  if audio_data.ndim == 2:
73
  audio_data = audio_data.mean(axis=1)
@@ -79,7 +80,10 @@ def run_pipeline(audio_path, src_lang="auto", tgt_lang="te",
79
  if opt_stutters:
80
  audio_data, n_s = denoiser._remove_stutters(audio_data, sr, word_segs)
81
  stats["stutters_removed"] = n_s
82
- sf.write(clean1, audio_data, sr, subtype="PCM_24")
 
 
 
83
  else:
84
  stats["fillers_removed"] = 0
85
  stats["stutters_removed"] = 0
 
68
  if (opt_fillers or opt_stutters) and word_segs:
69
  yield {"status": "processing", "step": 3, "message": "Step 3/5 — Removing fillers & stutters..."}
70
  import soundfile as sf
71
+ # Read the denoised audio — soundfile can read both WAV and MP3
72
  audio_data, sr = sf.read(clean1)
73
  if audio_data.ndim == 2:
74
  audio_data = audio_data.mean(axis=1)
 
80
  if opt_stutters:
81
  audio_data, n_s = denoiser._remove_stutters(audio_data, sr, word_segs)
82
  stats["stutters_removed"] = n_s
83
+ # Write to a fresh .wav PCM_24 is WAV-only, never write to .mp3 path
84
+ clean_wav = os.path.join(out_dir, "clean_step3.wav")
85
+ sf.write(clean_wav, audio_data, sr, format="WAV", subtype="PCM_24")
86
+ clean1 = clean_wav # downstream steps (Cloudinary upload) use this
87
  else:
88
  stats["fillers_removed"] = 0
89
  stats["stutters_removed"] = 0