Skip to content

Commit

Permalink
Removed some unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinJ committed Jun 20, 2019
1 parent 5abcce4 commit 0908e4d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 67 deletions.
26 changes: 0 additions & 26 deletions synthesizer/synthesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,3 @@ def run_synthesis(in_dir, out_dir, model_dir, hparams):
print("Synthesized mel spectrograms at {}".format(synth_dir))
return meta_out_fpath


def tacotron_synthesize(args, hparams, checkpoint, sentences=None):
output_dir = args.output_dir

try:
checkpoint_path = tf.train.get_checkpoint_state(checkpoint).model_checkpoint_path
log("loaded model at {}".format(checkpoint_path))
except:
raise RuntimeError("Failed to load checkpoint at {}".format(checkpoint))

if hparams.tacotron_synthesis_batch_size < hparams.tacotron_num_gpus:
raise ValueError("Defined synthesis batch size {} is smaller than minimum required {} "
"(num_gpus)! Please verify your synthesis batch size choice.".format(
hparams.tacotron_synthesis_batch_size, hparams.tacotron_num_gpus))

if hparams.tacotron_synthesis_batch_size % hparams.tacotron_num_gpus != 0:
raise ValueError("Defined synthesis batch size {} is not a multiple of {} (num_gpus)! "
"Please verify your synthesis batch size choice!".format(
hparams.tacotron_synthesis_batch_size, hparams.tacotron_num_gpus))

if args.mode == "eval":
return run_eval(args, checkpoint_path, output_dir, hparams, sentences)
elif args.mode == "synthesis":
return run_synthesis(args, checkpoint_path, output_dir, hparams)
else:
run_live(args, checkpoint_path, hparams)
47 changes: 7 additions & 40 deletions synthesizer/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,46 +330,13 @@ def train(log_dir, args, hparams):
saver.save(sess, checkpoint_fpath, global_step=global_step)

log("\nSaving alignment, Mel-Spectrograms and griffin-lim inverted waveform..")
if hparams.predict_linear:
input_seq, mel_prediction, linear_prediction, alignment, target, target_length, linear_target = sess.run(
[
model.tower_inputs[0][0],
model.tower_mel_outputs[0][0],
model.tower_linear_outputs[0][0],
model.tower_alignments[0][0],
model.tower_mel_targets[0][0],
model.tower_targets_lengths[0][0],
model.tower_linear_targets[0][0],
])

# save predicted linear spectrogram to disk (debug)
linear_filename = "linear-prediction-step-{}.npy".format(step)
np.save(os.path.join(linear_dir, linear_filename), linear_prediction.T,
allow_pickle=False)

# save griffin lim inverted wav for debug (linear -> wav)
wav = audio.inv_linear_spectrogram(linear_prediction.T, hparams)
audio.save_wav(wav, os.path.join(wav_dir, "step-{}-wave-from-linear.wav"
"".format(step)),
sr=hparams.sample_rate)

# Save real and predicted linear-spectrogram plot to disk (control purposes)
plot.plot_spectrogram(linear_prediction, os.path.join(plot_dir,
"step-{}-linear-spectrogram.png".format(
step)),
title="{}, {}, step={}, loss={:.5f}".format(
"Tacotron", time_string(), step, loss),
target_spectrogram=linear_target,
max_len=target_length, auto_aspect=True)

else:
input_seq, mel_prediction, alignment, target, target_length = sess.run([
model.tower_inputs[0][0],
model.tower_mel_outputs[0][0],
model.tower_alignments[0][0],
model.tower_mel_targets[0][0],
model.tower_targets_lengths[0][0],
])
input_seq, mel_prediction, alignment, target, target_length = sess.run([
model.tower_inputs[0][0],
model.tower_mel_outputs[0][0],
model.tower_alignments[0][0],
model.tower_mel_targets[0][0],
model.tower_targets_lengths[0][0],
])

# save predicted mel spectrogram to disk (debug)
mel_filename = "mel-prediction-step-{}.npy".format(step)
Expand Down
2 changes: 1 addition & 1 deletion vocoder/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def progbar(i, n, size=16):


def stream(message) :
sys.stdout.write(f"\r{message}")
sys.stdout.write("\r{%s}" % message)


def simple_table(item_tuples) :
Expand Down
1 change: 1 addition & 0 deletions vocoder/models/deepmind_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from utils.display import *
from utils.dsp import *


class WaveRNN(nn.Module) :
def __init__(self, hidden_size=896, quantisation=256) :
super(WaveRNN, self).__init__()
Expand Down

0 comments on commit 0908e4d

Please sign in to comment.