File size: 1,091 Bytes
1919b5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Float-source parity vs the published ITW score file: run from this dir:
#   python source_parity_float.py <module> <ssl_name> <N>   (reads the original float wavs, not the PCM_16 parquet)
import os, sys, numpy as np, soundfile as sf, torch, importlib
sys.path.insert(0, os.getcwd())
W = importlib.import_module(sys.argv[1]); ssl = sys.argv[2]; N = int(sys.argv[3])
SRC = "/home/kirill/mnt/users_4tb/datasets/release_in_the_wild"
pub = {}
for line in open(f"../_ckpt_dl/issf__spoof-superb-scores/raw/linear_head/in_the_wild/{ssl}.txt"):
    p = line.split(); pub[int(p[0])] = float(p[-1])
ids = list(range(N))
aud = [sf.read(f"{SRC}/{i}.wav", dtype="float32")[0] for i in ids]
m = [c for n, c in vars(W).items() if n.startswith("SpoofSUPERB") and isinstance(c, type)][0](); m.load()
pv = np.array([pub[i] for i in ids])
for tf in (False, True):
    torch.backends.cudnn.allow_tf32 = tf
    s = np.array(sum((m.score_batch(aud[k:k+16], [16000]*16) for k in range(0, N, 16)), []))
    print(f"float source, cudnn_tf32={tf}: max|d|={np.abs(pv-s).max():.3g} mean|d|={np.abs(pv-s).mean():.3g}")