mirror of
https://github.com/xiph/opus.git
synced 2025-05-29 06:39:15 +00:00
stashing stuff here
This commit is contained in:
parent
679dfbab58
commit
374ba430c4
4 changed files with 21 additions and 19 deletions
|
@ -577,6 +577,7 @@ int main(int argc, char **argv) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (i=0;i<FRAME_SIZE;i++) x[i] = tmp[i];
|
for (i=0;i<FRAME_SIZE;i++) x[i] = tmp[i];
|
||||||
|
for (i=0;i<FRAME_SIZE;i++) x[i] += rand()/(float)RAND_MAX - .5;
|
||||||
for (i=0;i<FRAME_SIZE;i++) E += tmp[i]*(float)tmp[i];
|
for (i=0;i<FRAME_SIZE;i++) E += tmp[i]*(float)tmp[i];
|
||||||
biquad(x, mem_hp_x, x, b_hp, a_hp, FRAME_SIZE);
|
biquad(x, mem_hp_x, x, b_hp, a_hp, FRAME_SIZE);
|
||||||
preemphasis(x, &mem_preemph, x, PREEMPHASIS, FRAME_SIZE);
|
preemphasis(x, &mem_preemph, x, PREEMPHASIS, FRAME_SIZE);
|
||||||
|
|
|
@ -12,7 +12,7 @@ import sys
|
||||||
rnn_units=512
|
rnn_units=512
|
||||||
pcm_bits = 8
|
pcm_bits = 8
|
||||||
pcm_levels = 2**pcm_bits
|
pcm_levels = 2**pcm_bits
|
||||||
nb_used_features = 37
|
nb_used_features = 38
|
||||||
|
|
||||||
|
|
||||||
def new_wavernn_model():
|
def new_wavernn_model():
|
||||||
|
@ -22,11 +22,11 @@ def new_wavernn_model():
|
||||||
dec_feat = Input(shape=(None, 32))
|
dec_feat = Input(shape=(None, 32))
|
||||||
dec_state = Input(shape=(rnn_units,))
|
dec_state = Input(shape=(rnn_units,))
|
||||||
|
|
||||||
conv1 = Conv1D(16, 7, padding='causal')
|
conv1 = Conv1D(16, 7, padding='causal', activation='tanh')
|
||||||
pconv1 = Conv1D(16, 5, padding='same')
|
pconv1 = Conv1D(16, 5, padding='same', activation='tanh')
|
||||||
pconv2 = Conv1D(16, 5, padding='same')
|
pconv2 = Conv1D(16, 5, padding='same', activation='tanh')
|
||||||
fconv1 = Conv1D(128, 3, padding='same')
|
fconv1 = Conv1D(128, 3, padding='same', activation='tanh')
|
||||||
fconv2 = Conv1D(32, 3, padding='same')
|
fconv2 = Conv1D(32, 3, padding='same', activation='tanh')
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
cpcm = conv1(pcm)
|
cpcm = conv1(pcm)
|
||||||
|
@ -40,17 +40,17 @@ def new_wavernn_model():
|
||||||
rep = Lambda(lambda x: K.repeat_elements(x, 160, 1))
|
rep = Lambda(lambda x: K.repeat_elements(x, 160, 1))
|
||||||
|
|
||||||
rnn = CuDNNGRU(rnn_units, return_sequences=True, return_state=True)
|
rnn = CuDNNGRU(rnn_units, return_sequences=True, return_state=True)
|
||||||
rnn_in = Concatenate()([cpcm, cpitch, rep(cfeat)])
|
rnn_in = Concatenate()([cpcm, rep(cfeat)])
|
||||||
md = MDense(pcm_levels, activation='softmax')
|
md = MDense(pcm_levels, activation='softmax')
|
||||||
gru_out, state = rnn(rnn_in)
|
gru_out, state = rnn(rnn_in)
|
||||||
ulaw_prob = md(gru_out)
|
ulaw_prob = md(gru_out)
|
||||||
|
|
||||||
model = Model([pcm, pitch, feat], ulaw_prob)
|
model = Model([pcm, feat], ulaw_prob)
|
||||||
encoder = Model(feat, cfeat)
|
encoder = Model(feat, cfeat)
|
||||||
|
|
||||||
dec_rnn_in = Concatenate()([cpcm, cpitch, dec_feat])
|
dec_rnn_in = Concatenate()([cpcm, dec_feat])
|
||||||
dec_gru_out, state = rnn(dec_rnn_in, initial_state=dec_state)
|
dec_gru_out, state = rnn(dec_rnn_in, initial_state=dec_state)
|
||||||
dec_ulaw_prob = md(dec_gru_out)
|
dec_ulaw_prob = md(dec_gru_out)
|
||||||
|
|
||||||
decoder = Model([pcm, pitch, dec_feat, dec_state], [dec_ulaw_prob, state])
|
decoder = Model([pcm, dec_feat, dec_state], [dec_ulaw_prob, state])
|
||||||
return model, encoder, decoder
|
return model, encoder, decoder
|
||||||
|
|
|
@ -47,7 +47,7 @@ in_data = np.reshape(in_data, (nb_frames*pcm_chunk_size, 1))
|
||||||
out_data = np.reshape(data, (nb_frames*pcm_chunk_size, 1))
|
out_data = np.reshape(data, (nb_frames*pcm_chunk_size, 1))
|
||||||
|
|
||||||
|
|
||||||
model.load_weights('lpcnet1i_30.h5')
|
model.load_weights('lpcnet3a_21.h5')
|
||||||
|
|
||||||
order = 16
|
order = 16
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ for c in range(1, nb_frames):
|
||||||
cfeat = enc.predict(features[c:c+1, :, :nb_used_features])
|
cfeat = enc.predict(features[c:c+1, :, :nb_used_features])
|
||||||
for fr in range(1, feature_chunk_size):
|
for fr in range(1, feature_chunk_size):
|
||||||
f = c*feature_chunk_size + fr
|
f = c*feature_chunk_size + fr
|
||||||
a = features[c, fr, nb_used_features+1:]
|
a = features[c, fr, nb_used_features:]
|
||||||
|
|
||||||
#print(a)
|
#print(a)
|
||||||
gain = 1.;
|
gain = 1.;
|
||||||
|
@ -69,9 +69,10 @@ for c in range(1, nb_frames):
|
||||||
period = period - 4
|
period = period - 4
|
||||||
for i in range(frame_size):
|
for i in range(frame_size):
|
||||||
pitch[0, 0, 0] = exc[f*frame_size + i - period, 0]
|
pitch[0, 0, 0] = exc[f*frame_size + i - period, 0]
|
||||||
fexc[0, 0, 0] = exc[f*frame_size + i - 1]
|
fexc[0, 0, 0] = 2*exc[f*frame_size + i - 1]
|
||||||
|
#fexc[0, 0, 0] = in_data[f*frame_size + i, 0]
|
||||||
#print(cfeat.shape)
|
#print(cfeat.shape)
|
||||||
p, state = dec.predict([fexc, pitch, cfeat[:, fr:fr+1, :], state])
|
p, state = dec.predict([fexc, cfeat[:, fr:fr+1, :], state])
|
||||||
p = p/(1e-5 + np.sum(p))
|
p = p/(1e-5 + np.sum(p))
|
||||||
#print(np.sum(p))
|
#print(np.sum(p))
|
||||||
iexc[0, 0, 0] = np.argmax(np.random.multinomial(1, p[0,0,:], 1))-128
|
iexc[0, 0, 0] = np.argmax(np.random.multinomial(1, p[0,0,:], 1))-128
|
||||||
|
|
|
@ -13,13 +13,13 @@ from adadiff import Adadiff
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
from keras.backend.tensorflow_backend import set_session
|
from keras.backend.tensorflow_backend import set_session
|
||||||
config = tf.ConfigProto()
|
config = tf.ConfigProto()
|
||||||
config.gpu_options.per_process_gpu_memory_fraction = 0.28
|
config.gpu_options.per_process_gpu_memory_fraction = 0.44
|
||||||
set_session(tf.Session(config=config))
|
set_session(tf.Session(config=config))
|
||||||
|
|
||||||
nb_epochs = 40
|
nb_epochs = 40
|
||||||
batch_size = 64
|
batch_size = 64
|
||||||
|
|
||||||
model = lpcnet.new_wavernn_model()
|
model, enc, dec = lpcnet.new_wavernn_model()
|
||||||
model.compile(optimizer=Adadiff(), loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
|
model.compile(optimizer=Adadiff(), loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
|
||||||
model.summary()
|
model.summary()
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@ features = features[:, :, :nb_used_features]
|
||||||
# f.create_dataset('data', data=in_data[:50000, :, :])
|
# f.create_dataset('data', data=in_data[:50000, :, :])
|
||||||
# f.create_dataset('feat', data=features[:50000, :, :])
|
# f.create_dataset('feat', data=features[:50000, :, :])
|
||||||
|
|
||||||
checkpoint = ModelCheckpoint('lpcnet1k_{epoch:02d}.h5')
|
checkpoint = ModelCheckpoint('lpcnet3b_{epoch:02d}.h5')
|
||||||
|
|
||||||
#model.load_weights('wavernn1c_01.h5')
|
#model.load_weights('wavernn1c_01.h5')
|
||||||
model.compile(optimizer=Adadiff(), loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
|
model.compile(optimizer=Adam(0.001, amsgrad=True, decay=2e-4), loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
|
||||||
model.fit([in_data, in_pitch, features], out_data, batch_size=batch_size, epochs=30, validation_split=0.2, callbacks=[checkpoint])
|
model.fit([in_data, features], out_data, batch_size=batch_size, epochs=30, validation_split=0.2, callbacks=[checkpoint])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue