deveix commited on
Commit
0aa7816
·
1 Parent(s): 19a4c6d

fix preprocessing

Browse files
Files changed (1) hide show
  1. app/main.py +3 -3
app/main.py CHANGED
@@ -154,6 +154,7 @@ def preprocess_audio(path, save_dir):
154
  y_no_gaps = np.concatenate([y[start:end] for start, end in intervals])
155
 
156
  file_name_without_extension = os.path.basename(path).split('.')[0]
 
157
  y_trimmed, _ = librosa.effects.trim(y_no_gaps, top_db = 20)
158
  D = librosa.stft(y)
159
  S_db = librosa.amplitude_to_db(np.abs(D), ref=np.max)
@@ -190,12 +191,11 @@ def preprocess_audio(path, save_dir):
190
 
191
  # Feature Extraction (example: MFCCs)
192
  # mfccs = librosa.feature.mfcc(y=y_normalized, sr=target_sr, n_mfcc=20)
193
-
194
 
195
- output_file_path = os.path.join(save_dir, f"{file_name_without_extension}.wav")
196
 
197
  # Write the audio data to the output file in .wav format
198
- sf.write(output_file_path, y_normalized, target_sr)
199
 
200
  return 'success'
201
 
 
154
  y_no_gaps = np.concatenate([y[start:end] for start, end in intervals])
155
 
156
  file_name_without_extension = os.path.basename(path).split('.')[0]
157
+ extension = os.path.basename(path).split('.')[1]
158
  y_trimmed, _ = librosa.effects.trim(y_no_gaps, top_db = 20)
159
  D = librosa.stft(y)
160
  S_db = librosa.amplitude_to_db(np.abs(D), ref=np.max)
 
191
 
192
  # Feature Extraction (example: MFCCs)
193
  # mfccs = librosa.feature.mfcc(y=y_normalized, sr=target_sr, n_mfcc=20)
 
194
 
195
+ # output_file_path = os.path.join(save_dir, f"{file_name_without_extension}.{extension}")
196
 
197
  # Write the audio data to the output file in .wav format
198
+ sf.write(path, y_normalized, target_sr)
199
 
200
  return 'success'
201