From d02dd4795822505e26d714cb38d8ef6dae6e6d30 Mon Sep 17 00:00:00 2001 From: Eren Golge Date: Thu, 3 May 2018 05:56:33 -0700 Subject: [PATCH] Add stop token visualizaiotn for the notebook --- notebooks/utils.py | 13 +++++++++---- utils/visual.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/notebooks/utils.py b/notebooks/utils.py index b37a7241..b492fc61 100644 --- a/notebooks/utils.py +++ b/notebooks/utils.py @@ -34,20 +34,25 @@ def create_speech(m, s, CONFIG, use_cuda, ap): return wav, alignment, spec, stop_tokens -def visualize(alignment, spectrogram, CONFIG): +def visualize(alignment, spectrogram, stop_tokens, CONFIG): label_fontsize = 16 - plt.figure(figsize=(16, 16)) + plt.figure(figsize=(16, 24)) - plt.subplot(2, 1, 1) + plt.subplot(3, 1, 1) plt.imshow(alignment.T, aspect="auto", origin="lower", interpolation=None) plt.xlabel("Decoder timestamp", fontsize=label_fontsize) plt.ylabel("Encoder timestamp", fontsize=label_fontsize) plt.colorbar() + + plt.subplot(3, 1, 2) + plt.plot(range(len(stop_tokens)), list(stop_tokens)) - plt.subplot(2, 1, 2) + plt.subplot(3, 1, 3) librosa.display.specshow(spectrogram.T, sr=CONFIG.sample_rate, hop_length=hop_length, x_axis="time", y_axis="linear") plt.xlabel("Time", fontsize=label_fontsize) plt.ylabel("Hz", fontsize=label_fontsize) plt.tight_layout() plt.colorbar() + + \ No newline at end of file diff --git a/utils/visual.py b/utils/visual.py index 0c24a251..1cf50f5d 100644 --- a/utils/visual.py +++ b/utils/visual.py @@ -32,4 +32,4 @@ def plot_spectrogram(linear_output, audio): data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep='') data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,)) plt.close() - return data + return data \ No newline at end of file