Let's say I have two audio clips: 1a.mp3 and 1b.mp3
1a is 1.04s. 1b is 1.01s
or
1a is 1.01s. 1b is 1.04s
How can I change the speed of 1b so that the resulting clip would be the same as 1a.
Here's a visual representation of what I want to do: https://youtu.be/nyh_wBGz2Bk
I tried following this SO post but the resulting clips were not the correct length: How to change audio playback speed using Pydub?
Here's the code I have:
from pydub.effects import speedup
from pydub import AudioSegment
def speed_up_audio(input_file, speed_factor):
audio = AudioSegment.from_file(input_file)
sped_up_audio = speedup(audio, speed_factor)
return sped_up_audio
speed_factor = 1b_audio_len/1a_audio_len
sped_clip = speed_up_audio(1b_mp3_file_path, speed_factor)