mirror of
https://github.com/xiph/opus.git
synced 2025-05-30 15:17:42 +00:00
Fix input noise
This commit is contained in:
parent
08b5fe6cdc
commit
a922f83cca
2 changed files with 10 additions and 6 deletions
|
@ -66,7 +66,7 @@ in_data = np.reshape(in_data, (nb_frames*pcm_chunk_size, 1))
|
|||
out_data = np.reshape(data, (nb_frames*pcm_chunk_size, 1))
|
||||
|
||||
|
||||
model.load_weights('wavenet3h13_30.h5')
|
||||
model.load_weights('wavenet3h21_30.h5')
|
||||
|
||||
order = 16
|
||||
|
||||
|
@ -90,11 +90,13 @@ for c in range(1, nb_frames):
|
|||
fexc[0, 0, 1] = np.minimum(127, lin2ulaw(pred/32768.)) + 128
|
||||
|
||||
p, state = dec.predict([fexc, cfeat[:, fr:fr+1, :], state])
|
||||
#p = p*p
|
||||
#p = p/(1e-18 + np.sum(p))
|
||||
p = np.maximum(p-0.001, 0)
|
||||
p = p/(1e-5 + np.sum(p))
|
||||
|
||||
iexc[0, 0, 0] = np.argmax(np.random.multinomial(1, p[0,0,:], 1))-128
|
||||
pcm[f*frame_size + i, 0] = 32768*ulaw2lin(iexc[0, 0, 0]*1.0)
|
||||
print(iexc[0, 0, 0], out_data[f*frame_size + i, 0], pcm[f*frame_size + i, 0])
|
||||
print(iexc[0, 0, 0], 32768*ulaw2lin(out_data[f*frame_size + i, 0]), pcm[f*frame_size + i, 0], pred)
|
||||
|
||||
|
||||
|
|
|
@ -45,21 +45,23 @@ data = data[:nb_frames*pcm_chunk_size]
|
|||
features = features[:nb_frames*feature_chunk_size*nb_features]
|
||||
|
||||
in_data = np.concatenate([data[0:1], data[:-1]]);
|
||||
in_data = in_data + np.random.randint(-1, 1, len(data))
|
||||
noise = np.concatenate([np.zeros((len(data)//3)), np.random.randint(-2, 2, len(data)//3), np.random.randint(-1, 1, len(data)//3)])
|
||||
in_data = in_data + noise
|
||||
in_data = np.maximum(-127, np.minimum(127, in_data))
|
||||
|
||||
features = np.reshape(features, (nb_frames*feature_chunk_size, nb_features))
|
||||
|
||||
pred = np.fromfile(pred_file, dtype='int16')
|
||||
pred = pred[:nb_frames*pcm_chunk_size]
|
||||
|
||||
pred_in = 32768.*ulaw2lin(data)
|
||||
pred_in = 32768.*ulaw2lin(in_data)
|
||||
for i in range(2, nb_frames*feature_chunk_size):
|
||||
pred[i*frame_size:(i+1)*frame_size] = 0
|
||||
if i % 100000 == 0:
|
||||
print(i)
|
||||
for k in range(16):
|
||||
pred[i*frame_size:(i+1)*frame_size] = pred[i*frame_size:(i+1)*frame_size] - \
|
||||
pred_in[i*frame_size-k-1:(i+1)*frame_size-k-1]*features[i, nb_features-16+k]
|
||||
pred_in[i*frame_size-k:(i+1)*frame_size-k]*features[i, nb_features-16+k]
|
||||
|
||||
pred = np.minimum(127, lin2ulaw(pred/32768.))
|
||||
#pred = pred + np.random.randint(-1, 1, len(data))
|
||||
|
@ -90,7 +92,7 @@ in_data = np.concatenate([in_data, pred], axis=-1)
|
|||
# f.create_dataset('data', data=in_data[:50000, :, :])
|
||||
# f.create_dataset('feat', data=features[:50000, :, :])
|
||||
|
||||
checkpoint = ModelCheckpoint('wavenet3h13_{epoch:02d}.h5')
|
||||
checkpoint = ModelCheckpoint('wavenet3h21_{epoch:02d}.h5')
|
||||
|
||||
#model.load_weights('wavernn1c_01.h5')
|
||||
model.compile(optimizer=Adam(0.001, amsgrad=True, decay=2e-4), loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue