From 5e679f746db2d9b49bdae43f90b0fa8b260f488d Mon Sep 17 00:00:00 2001 From: Eren Golge Date: Sun, 12 May 2019 17:35:44 +0200 Subject: [PATCH] save figures in visualize of set --- utils/visual.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/visual.py b/utils/visual.py index b259bdd9..2924b034 100644 --- a/utils/visual.py +++ b/utils/visual.py @@ -30,14 +30,14 @@ def plot_spectrogram(linear_output, audio): return fig -def visualize(alignment, spectrogram_postnet, stop_tokens, text, hop_length, CONFIG, spectrogram=None): +def visualize(alignment, spectrogram_postnet, stop_tokens, text, hop_length, CONFIG, spectrogram=None, output_path=None): if spectrogram is not None: num_plot = 4 else: num_plot = 3 label_fontsize = 16 - plt.figure(figsize=(8, 24)) + fig = plt.figure(figsize=(8, 24)) plt.subplot(num_plot, 1, 1) plt.imshow(alignment.T, aspect="auto", origin="lower", interpolation=None) @@ -69,3 +69,7 @@ def visualize(alignment, spectrogram_postnet, stop_tokens, text, hop_length, CON plt.ylabel("Hz", fontsize=label_fontsize) plt.tight_layout() plt.colorbar() + + if output_path: + print(output_path) + fig.savefig(output_path)