Fixing a bug

This commit is contained in:
parth aranke 2024-06-06 23:06:22 +05:30
parent eb88e7f9dc
commit dd88aac68e
2 changed files with 9 additions and 4 deletions

View File

@ -78,7 +78,10 @@ class ProceesAudio():
prev_gains = np.ones(10)
segments, sr = self._split_audio_s(data, sr=sr)
max_amp = 0
part_amps = []
part_amps = []
part_audios = []
for i in range(10):
part_audios.append([])
for segment in segments:
max_amp = max(max_amp, np.max(np.abs(segment)))
for segment, mod in zip(segments, new_amps):
@ -98,13 +101,15 @@ class ProceesAudio():
part_amp.append(gain)
audio = self.make_smooth(audio, gain, prev_gains[i])
curr_gains.append(gain)
for frame in audio:
part_audios[i].append(audio)
final_audios.append(audio)
part_amps.append(part_amp)
prev_gains = curr_gains
modified_seg = add_stereo(final_audios, len(final_audios[0]), sample_rate=sr)
modified_segs.append(modified_seg)
return modified_segs, part_amps
return modified_segs, part_amps, part_audios
def perform_modulation(self, data, sr, index):
segments, sr = self._split_audio_s(data, sr=sr)

View File

@ -68,12 +68,12 @@ def process_audio_bytes(audio_bytes, index):
pa = ProceesAudio()
processed_data, part_amps = pa.perform_modulation(data=data, sr=sample_rate, index=index)
processed_data, part_amps, part_audios = pa.perform_modulation(data=data, sr=sample_rate, index=index)
part_urls= []
for i in range(10):
url = upload_to_s3(processed_data=processed_data[i], userId="parth", type="part1")
url = upload_to_s3(processed_data=part_audios[i], userId="parth", type="part")
part_urls.append(url)
processed_data = np.concatenate(processed_data)