Fixing a bug
This commit is contained in:
parent
eb88e7f9dc
commit
dd88aac68e
7
Utils.py
7
Utils.py
@ -79,6 +79,9 @@ class ProceesAudio():
|
|||||||
segments, sr = self._split_audio_s(data, sr=sr)
|
segments, sr = self._split_audio_s(data, sr=sr)
|
||||||
max_amp = 0
|
max_amp = 0
|
||||||
part_amps = []
|
part_amps = []
|
||||||
|
part_audios = []
|
||||||
|
for i in range(10):
|
||||||
|
part_audios.append([])
|
||||||
for segment in segments:
|
for segment in segments:
|
||||||
max_amp = max(max_amp, np.max(np.abs(segment)))
|
max_amp = max(max_amp, np.max(np.abs(segment)))
|
||||||
for segment, mod in zip(segments, new_amps):
|
for segment, mod in zip(segments, new_amps):
|
||||||
@ -98,13 +101,15 @@ class ProceesAudio():
|
|||||||
part_amp.append(gain)
|
part_amp.append(gain)
|
||||||
audio = self.make_smooth(audio, gain, prev_gains[i])
|
audio = self.make_smooth(audio, gain, prev_gains[i])
|
||||||
curr_gains.append(gain)
|
curr_gains.append(gain)
|
||||||
|
for frame in audio:
|
||||||
|
part_audios[i].append(audio)
|
||||||
final_audios.append(audio)
|
final_audios.append(audio)
|
||||||
part_amps.append(part_amp)
|
part_amps.append(part_amp)
|
||||||
prev_gains = curr_gains
|
prev_gains = curr_gains
|
||||||
modified_seg = add_stereo(final_audios, len(final_audios[0]), sample_rate=sr)
|
modified_seg = add_stereo(final_audios, len(final_audios[0]), sample_rate=sr)
|
||||||
modified_segs.append(modified_seg)
|
modified_segs.append(modified_seg)
|
||||||
|
|
||||||
return modified_segs, part_amps
|
return modified_segs, part_amps, part_audios
|
||||||
|
|
||||||
def perform_modulation(self, data, sr, index):
|
def perform_modulation(self, data, sr, index):
|
||||||
segments, sr = self._split_audio_s(data, sr=sr)
|
segments, sr = self._split_audio_s(data, sr=sr)
|
||||||
|
@ -68,12 +68,12 @@ def process_audio_bytes(audio_bytes, index):
|
|||||||
|
|
||||||
pa = ProceesAudio()
|
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= []
|
part_urls= []
|
||||||
|
|
||||||
for i in range(10):
|
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)
|
part_urls.append(url)
|
||||||
|
|
||||||
processed_data = np.concatenate(processed_data)
|
processed_data = np.concatenate(processed_data)
|
||||||
|
Loading…
Reference in New Issue
Block a user