-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_old.py
37 lines (31 loc) · 897 Bytes
/
check_old.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import defense
# import defenseneg
import classify2
import scipy.io.wavfile as wav
import tensorflow as tf
import numpy as np
from tqdm import tqdm
import sys
import os
# Paths to perturbed/unperturbed audio samples
cleanDir = './commonvoice_subset2'
perturbedDir = './perturbed_subset'
# Create session
config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)
# Define noise ranges that are to be considered
noiseLevels = range(0, 11, 2)
# Create data to train distinguishing model
X = []
Y = []
_, audio = wav.read(sys.argv[1])
noisy = defense.perturbedOutputs(audio, noiseLevels)
outputs = [ classify2.getAudioPrediction(sess, x) for x in noisy]
newaud = classify2.getAudioPrediction(sess, audio)
print sys.argv[1]
print newaud
for i in outputs:
print i
# features = defense.constructFeatures(outputs)
# print(" ".join([str(x) for x in features]))