Im trying to figure out how to edit the ending of this string:
select_file = AudioSegment.from_(select_file)
what I'm trying to make it do is for the format of the file selected (In this case, a .wav file), to change the AudioSegment to extract for each file. I.e: If i select a ".mp3" file, AudioSegment.from_wav will change to AudioSegment.from_mp3.
How can i accomplish this? It seems that any attempt to make it flexible results in this error
AttributeError: type object 'AudioSegment' has no attribute 'from_SoundFile'
Here is the full code.
for file in os.listdir("Music"):
if file.endswith(".wav") or file.endswith(".mp3"):
print file
select_file = raw_input("Which file would you like to modify?")
if select_file in os.listdir("Music"):
os.chdir("Music")
print select_file
FileEnd = select_file.split(".")
print FileEnd[-1]
select_file = AudioSegment.from_SoundFile[-1](select_file)
SoundFile = { 'Name': select_file, 'format': FileEnd[-1]}
How do i make it so that the ending will change depending on the file ending? I don't need it to fit any specific type of code, so any answer is fine.