Jaman commited on
Commit
1c313a5
·
verified ·
1 Parent(s): c31d80d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -55,7 +55,7 @@ class AudioProcessor:
55
  reverb_room_size = min(max(avg_volume, 0.1), 0.5)
56
  return highpass_cutoff, compressor_threshold, reverb_room_size
57
 
58
- def master_audio(self):
59
  # Load the mixed and generated 24bit audio file
60
  print(f"Loading 24bit audio file: {self.mastered_24bit}")
61
  with AudioFile(self.mastered_24bit) as f:
@@ -81,8 +81,8 @@ class AudioProcessor:
81
  # Apply custom stereo widening
82
  processed_audio = self.stereo_widen(processed_audio)
83
 
84
- # Reduce piano volume
85
- processed_audio = self.reduce_piano_volume(processed_audio, sample_rate)
86
 
87
  # Save the processed audio to a new file
88
  output_file = 'final_mastered_audio.wav'
@@ -131,10 +131,15 @@ if uploaded_file is not None:
131
  # Initialize the processor
132
  processor = AudioProcessor(target_file=audio_file_path, reference_file=reference_file)
133
 
 
 
 
 
 
134
  if st.button('Master Audio'):
135
  with st.spinner('Mixing, generating, and mastering audio...'):
136
  processor.mix_and_generate()
137
- final_output = processor.master_audio()
138
 
139
  st.success('Audio mastering complete!')
140
  st.audio(final_output)
 
55
  reverb_room_size = min(max(avg_volume, 0.1), 0.5)
56
  return highpass_cutoff, compressor_threshold, reverb_room_size
57
 
58
+ def master_audio(self, freq_low=200, freq_high=2000, reduction_db=-18):
59
  # Load the mixed and generated 24bit audio file
60
  print(f"Loading 24bit audio file: {self.mastered_24bit}")
61
  with AudioFile(self.mastered_24bit) as f:
 
81
  # Apply custom stereo widening
82
  processed_audio = self.stereo_widen(processed_audio)
83
 
84
+ # Reduce piano volume with user-provided or default values
85
+ processed_audio = self.reduce_piano_volume(processed_audio, sample_rate, freq_low, freq_high, reduction_db)
86
 
87
  # Save the processed audio to a new file
88
  output_file = 'final_mastered_audio.wav'
 
131
  # Initialize the processor
132
  processor = AudioProcessor(target_file=audio_file_path, reference_file=reference_file)
133
 
134
+ # User input for reduce_piano_volume parameters
135
+ freq_low = st.number_input('Low Frequency Cut-off (Hz)', value=200)
136
+ freq_high = st.number_input('High Frequency Cut-off (Hz)', value=2000)
137
+ reduction_db = st.number_input('Volume Reduction (dB)', value=-18)
138
+
139
  if st.button('Master Audio'):
140
  with st.spinner('Mixing, generating, and mastering audio...'):
141
  processor.mix_and_generate()
142
+ final_output = processor.master_audio(freq_low=freq_low, freq_high=freq_high, reduction_db=reduction_db)
143
 
144
  st.success('Audio mastering complete!')
145
  st.audio(final_output)