ahk-d commited on
Commit
90de1d1
·
verified ·
1 Parent(s): 20ee97d

Update src/audio_preprocessing.py

Browse files
Files changed (1) hide show
  1. src/audio_preprocessing.py +6 -6
src/audio_preprocessing.py CHANGED
@@ -162,13 +162,13 @@ def denoise_audio(input_audio_path):
162
  audio = audio.set_channels(1) # Convert to mono
163
  audio = audio.set_sample_width(2) # Set to 16-bit
164
 
165
- # Export as RAW PCM
166
- temp_raw = "temp_audio.raw"
167
- audio.export(temp_raw, format="raw")
168
 
169
- # Run denoising on the RAW PCM data
170
  result = subprocess.run(
171
- ["denoise", temp_raw, output_audio_path, "--plot"],
172
  check=True,
173
  capture_output=True,
174
  text=True
@@ -176,7 +176,7 @@ def denoise_audio(input_audio_path):
176
  print(result.stdout)
177
 
178
  # Clean up
179
- os.remove(temp_raw)
180
 
181
  except subprocess.CalledProcessError as e:
182
  print(f"Error: {e}")
 
162
  audio = audio.set_channels(1) # Convert to mono
163
  audio = audio.set_sample_width(2) # Set to 16-bit
164
 
165
+ # Export as WAV with correct format
166
+ temp_wav = "temp_audio.wav"
167
+ audio.export(temp_wav, format="wav")
168
 
169
+ # Run denoising
170
  result = subprocess.run(
171
+ ["denoise", temp_wav, output_audio_path, "--plot"],
172
  check=True,
173
  capture_output=True,
174
  text=True
 
176
  print(result.stdout)
177
 
178
  # Clean up
179
+ os.remove(temp_wav)
180
 
181
  except subprocess.CalledProcessError as e:
182
  print(f"Error: {e}")