I have the code

import sound

def rem_vocals(snd):
    '''Return a copy of the original sound with vocals removed. The original sound is unmodified. The number of samples in the copied sound is the same as the original file.'''
    new_song=sound.copy(snd)
    for samp in new_song:
        left=(sound.get_left(samp))
        right=(sound.get_right(samp))
        result=(left-right)/2.0
        Left=sound.set_left(samp, int (result))
        Right=sound.set_right(samp, int (result))
        Left1=(sound.get_left(samp))
        Right1=(sound.get_right(samp))
    return new_song

if __name__ == '__main__':
    song=sound.load_sound('love.wav')

Question: How do I play the copy of my sound. sound.play(song) plays the original song, not the modified one. I then tried sound.play(new_song) which invokes an error. So what do I put inside the () to play the modified song? Thanks.

rem_vocals(sound)

I don't mean that. I already called the function. I mean how do I play the copied song using the sound.play function?

Should be like pyTony says call sound.play(rem_vocals(sound)) because your rem_vocals function is returning the new__song. But are you sure your error is not from import sound. I don't see any module that exists with that name unless you have made it yourself.

commented: gj +8

Ok, thanks for the clarifying! sound.play(rem_vocals(song)) works! I thought pyTony meant to call the function! No, I did not create the sound module. If you go to python 2.7 and key in import sound and then dir(sound) in the python shell, you will see a huge list of info.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.