MCPcopy Create free account
hub / github.com/dangf15/THLNet / checkcausal_net

Function checkcausal_net

utils.py:112–142  ·  view source on GitHub ↗

The whole pipeline give a latency of aec_shift + net win = 48ms

(net)

Source from the content-addressed store, hash-verified

110
111
112def checkcausal_net(net):
113 """
114 The whole pipeline give a latency of aec_shift + net win = 48ms
115 """
116 net_causal = net()
117 net_causal = net_causal.eval()
118 d = torch.device('cpu')
119 noisy_wavs = torch.randn([1,1,16000]).clamp_(-1,1)
120 # net_causal, net_noncal = net_causal.to(d).eval(), net_noncal.to(d).eval()
121 # noisy_wavs = noisy_wavs.to(d)
122 # noncausal model uses utt-level info
123 noisy_wavs[0,0,-1] = np.nan
124 out = net_causal(noisy_wavs)
125
126 # assert torch.isnan(out[0,0,0]) or torch.isinf(out[0,0,0])
127 '''
128 with torch.no_grad():
129 out1 = net_causal(noisy_wavs)[0].squeeze()
130 for i in range(512*16,512*18,fs):
131 noisy_wavs2 = noisy_wavs.clone()
132 noisy_wavs2[0,2,i:] = 1000 + torch.rand_like(noisy_wavs2[0,2,i:])
133 out2 = net_causal(noisy_wavs2)[0].squeeze()
134 print((i-((out1-out2).abs()>1e-8).float().argmax())/fs)
135 print((i-((out1-out2).abs()>1e-8).float().argmax())/fs)
136 for i in range(512*16,512*18,fs):
137 noisy_wavs2 = noisy_wavs.clone()
138 noisy_wavs2[0,1,i:] = 1000 + torch.rand_like(noisy_wavs2[0,1,i:])
139 out2 = net_causal(noisy_wavs2)[0].squeeze()
140 print((i-((out1-out2).abs()>1e-8).float().argmax())/fs)
141 print((i-((out1-out2).abs()>1e-8).float().argmax())/fs)
142 '''

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected