elif len(idx) == 1: code = codebook[idx] else: if prev_code is not None: code = prev_code else: code = codebook[0] arr[i] = code prev_code = code return arr print len(X) for i in [0, 3, 5, 8, 13]: lsf = reconstruct(lsf_tf.cluster_centers_, X[i][:, :n_lsf_clusters], n_features) a = lsf_to_lpc(lsf) gain = reconstruct(gain_tf.cluster_centers_, X[i][:, -n_gain_clusters:], 1) X_s = lpc_synthesis(a, gain, window_step=window_step) wavfile.write('orig_%i.wav' % i, fs, soundsc(X_s)) model = test_rnnrbm(X, num_epochs=200) n_samples_to_gen = 5 for i in range(n_samples_to_gen): g = model.generate() #f = open('sample_peach_pickle_rnndbn_%i.pkl' % i, 'w') #cPickle.dump(g,f) #f.close() lsf = reconstruct(lsf_tf.cluster_centers_, g[:, :n_lsf_clusters], n_features) a = lsf_to_lpc(lsf)
code = codebook[idx] else: if prev_code is not None: # If there are none active just use the previous code = prev_code else: # Very first sample is messed up... just pick one code = codebook[0] arr[i] = code prev_code = code return arr for i in [0, 20, 40, 60, 80, 100]: lsf = reconstruct(lsf_tf.cluster_centers_, X[i][:, :n_lsf_clusters], n_features) a = lsf_to_lpc(lsf) gain = reconstruct(gain_tf.cluster_centers_, X[i][:, -n_gain_clusters:], 1) X_s = lpc_synthesis(a, gain, window_step=window_step) wavfile.write('orig_%i.wav' % i, fs, soundsc(X_s)) model = test_lstmrbm(X, num_epochs=200) n_samples_to_gen = 5 for i in range(n_samples_to_gen): g = model.generate() lsf = reconstruct(lsf_tf.cluster_centers_, g[:, :n_lsf_clusters], n_features) a = lsf_to_lpc(lsf) gain = reconstruct(gain_tf.cluster_centers_, g[:, -n_gain_clusters:], 1) X_s = lpc_synthesis(a, gain, window_step=window_step)