0

I'm trying to create a function that will remove the vocals from the multiple wav files in a folder but keep running into an index error. I am new to python so am not sure where the issue is arising from but i think it might stem from the way i reference the file path in the function call though I can not actually be sure. any suggestions?

from pydub import AudioSegment
from pydub.playback import play


def vocalremover(advertaudio):

sound_stereo = AudioSegment.from_wav(advertaudio)
sound_monoR = sound_stereo.split_to_mono()[1]
sound_monoL = sound_stereo.split_to_mono()[0]


sound_monoR_inv = sound_monoR.invert_phase()


sound_CentersOut = sound_monoL.overlay(sound_monoR_inv)


sound_CentersOut.export(str(advertaudio), format="wav")





vocalremover(r'C:\Users\Jan\OneDrive - Media 
Ltd\normalized\201901150009_Proxy.wav')

it returns the error:


IndexError Traceback (most recent call last) in ----> 1 vocalremover(r'C:\Users\Jane\OneDrive - Jeli Media Ltd\clearcast\normalized\201901150009_Proxy.wav')

in vocalremover(advertaudio)

----> 9 sound_monoR = sound_stereo.split_to_mono()[1]

IndexError: list index out of range

1 Answers1

0
def vocalremover(advertaudio):

    sound_stereo = AudioSegment.from_wav(advertaudio)
    sound_monoR = sound_stereo.split_to_mono()[0][1]
    sound_monoL = sound_stereo.split_to_mono()[0][0]


    sound_monoR_inv = sound_monoR.invert_phase()


    sound_CentersOut = sound_monoL.overlay(sound_monoR_inv)


    sound_CentersOut.export(str(advertaudio), format="wav")

doing this worked but the file doesn't seem to play anything, try yourself and report back

Vady
  • 16
  • 3
  • i don't think it is. the function definition runs fine, it's when i try to use it that the error occurs. – Oluremi Falowo Apr 10 '19 at 15:53
  • it does run fine, but it says that it doesn't have [1], as in, it doesn't give you a right channel for some reason. – Vady Apr 10 '19 at 15:58