GithubHelp home page GithubHelp logo

fraunhofer-aisec / towards-resistant-audio-adversarial-examples Goto Github PK

View Code? Open in Web Editor NEW
9.0 5.0 4.0 106 KB

Generation tool for offset-resistant audio adversarial examples against Deepspeech

Home Page: https://tom-doerr.github.io/website_towards_resistant_audio_adversarial_examples/

License: BSD 2-Clause "Simplified" License

Python 89.38% Dockerfile 9.49% Shell 1.13%
deepspeech adversarial-example machine-learning speech-recognition paper

towards-resistant-audio-adversarial-examples's Introduction

Accompanying Website

To generate adversarial examples for your own files, follow the below process and modify the arguments to attack,py. Ensure that the file is sampled at 16KHz and uses signed 16-bit ints as the data type. You may want to modify the number of iterations that the attack algorithm is allowed to run.

Setup

  1. Install Docker. On Ubuntu/Debian/Linux-Mint etc.:
sudo apt-get install docker.io
sudo systemctl enable --now docker

Instructions for other platforms: https://docs.docker.com/install/

  1. Download DeepSpeech and build the Docker images:
./setup.sh

With Nvidia-GPU support:

  1. Install the NVIDIA Container Toolkit. This step will only work on Linux and is only necessary if you want GPU support. As far as I know it's not possible to use a GPU with docker under Windows/Mac. On Ubuntu/Debian/Linux-Mint etc. you can install the toolkit with the following commands:
# Add the package repositories
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker

Instructions for other platforms (CentOS/RHEL): https://github.com/NVIDIA/nvidia-docker

  1. Start the container using the GPU image we just build:
docker run --gpus all -it --mount src=$(pwd),target=/audio_adversarial_examples,type=bind -w /audio_adversarial_examples aae_deepspeech_041_gpu

CPU-only (Skip if already started with Nvidia-GPU support):

  1. Start the container using the CPU image we just build:
docker run -it --mount src=$(pwd),target=/audio_adversarial_examples,type=bind -w /audio_adversarial_examples aae_deepspeech_041_cpu

Basic usage

Classify audio sample-000000.wav

python3 classify.py sample-000000.wav

Generate an adversarial example

python3 attack.py --in sample-000000.wav --target "this is a test" --out adv.wav --iterations 1000 --restore_path deepspeech-0.4.1-checkpoint/model.v0.4.1

Add offset to audio file adv.wav

python3 add_silence_to_start.py adv.wav

Classify audio file adv.wav with an added offset of 121 samples

python3 classify.py offset_audio_added/adv/121.wav

Classify all audio offset files for adv.wav

python3 classify.py offset_audio_added/adv/*.wav

Plot the edit distance for different offsets. Run the following command outside of the docker container (you might need to run pip install -r requirements.txt first):

python3 plot.py offset_audio_added/adv/

The code in this repo is based on the code from Audio Adversarial Examples.

towards-resistant-audio-adversarial-examples's People

Contributors

tom-doerr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.