Skip to content

Commit

Permalink
[feature] composer - samples from saved DCGAN to create bad songs
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkel committed Mar 30, 2016
1 parent 28b5f24 commit 734adf4
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions composer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os
import numpy as np
import tensorflow as tf

from glob import glob
from model import DCGAN
from utils import pp, visualize, to_json
import tensorflow_wav


dataset="audio"
wav_size=64
is_crop=False
batch_size=16
checkpoint_dir="checkpoint"
bitrate=4096

with tf.Session() as sess:
dcgan = DCGAN(sess, wav_size=wav_size, batch_size=batch_size,
dataset_name=dataset, is_crop=is_crop, checkpoint_dir=checkpoint_dir)
dcgan.load(checkpoint_dir)

data = glob(os.path.join("./training", "*.wav"))
sample_file = data[0]
sample =tensorflow_wav.get_wav(sample_file)

full_audio = []
for i in range(120):
audio = dcgan.sample()

audio = np.reshape(audio,[-1])
print("Audio shape", np.shape(audio))
full_audio += audio[:bitrate].tolist()
print("Full audio shape", np.shape(full_audio))

samplewav = sample.copy()
samplewav
samplewav['data']=full_audio
print("samplewav shape", np.shape(samplewav['data']))

filename = "./compositions/song.wav"
tensorflow_wav.save_wav(samplewav, filename )



0 comments on commit 734adf4

Please sign in to comment.