I have 2 .wav file, one contains the original audio (original.wav), while the other contains perturbation (attacked.wav)which is generated from an audio adversarial example attack code.
How can i extract the perturbation as a separate perturbation.wav file by comparing the original.wav files with attacked.wav preferably using python3
think of it this way ... you have a value 7 then you perturb this by an as of yet unknown force which results in changing your original value into a value 9 ... what arithmetic operation can you perform using these two values to identify the perturbation ?
Do not over think this ... once you have solved this thought experiment the same principles apply to solving your question ...
Hint ... this same approach is how noise cancelling headphones work
now back to your challenge ... audio is a curve over time ... your wav audio file can be opened up and parsed into this audio curve its called PCM format ... its just points along this curve ... once you have opened up both of your files ( assume your recordings are both time aligned so beginning of the file on each represents the same instant in time ) then iterate across the audio curve of both files simultaneously and perform the same operation you discovered above to synthesize an output wav file of just the perturbation audio curve
before touching any code it would behoove you to be able to grok the trick we are using here