简体   繁体   English

从 .wav 文件中提取扰动

[英]Extracting perturbation from .wav file

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.我有 2 个 .wav 文件,一个包含原始音频(original.wav),而另一个包含由音频对抗示例攻击代码生成的扰动(attacked.wav)。

How can i extract the perturbation as a separate perturbation.wav file by comparing the original.wav files with attacked.wav preferably using python3如何通过将 original.wav 文件与attacked.wav 最好使用python3 进行比较,将扰动提取为单独的perturbation.wav 文件

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 ?这样想......你有一个值 7 然后你用一个未知的力量扰乱它,这导致你的原始值变成了一个值 9......你可以使用这两个值来执行什么算术运算来识别扰动?

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现在回到你的挑战......音频是一个随时间变化的曲线......你的wav音频文件可以被打开并解析成这个音频曲线,它称为PCM格式......它只是沿着这条曲线的点......一旦你有打开你的两个文件(假设你的录音都是时间对齐的,所以每个文件的开头代表同一时刻)然后同时遍历两个文件的音频曲线并执行你在上面发现的相同操作以合成输出只是扰动音频曲线的 wav 文件

before touching any code it would behoove you to be able to grok the trick we are using here在接触任何代码之前,您应该能够理解我们在这里使用的技巧

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM