Skip to content

Commit

Permalink
visualize bool
Browse files Browse the repository at this point in the history
  • Loading branch information
shuklabhay committed Nov 22, 2024
1 parent 87ee183 commit 0f091e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/data_processing/audio_processing_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def choose_random_sample():

if sample_path is not None:
print(sample_path)
signal_processing.stft_and_istft(sample_path, "test")
signal_processing.stft_and_istft(sample_path, "test", True)
10 changes: 7 additions & 3 deletions src/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import soundfile as sf
import torch
from numpy.typing import NDArray
import torch
from torch import nn

from .constants import SignalConstants, TrainingParams, ModelParams
Expand Down Expand Up @@ -427,7 +428,9 @@ def encode_sample_directory(

self.utils.save_loudness_data(output_dir, np.array(real_data))

def stft_and_istft(self, sample_path: str, file_name: str) -> None:
def stft_and_istft(
self, sample_path: str, file_name: str, visualize: bool = False
) -> None:
"""Perform a STFT and ISTFT operation."""
# Load data
y = self.utils.load_audio(sample_path, self.sample_length)
Expand All @@ -452,5 +455,6 @@ def stft_and_istft(self, sample_path: str, file_name: str) -> None:
save_path = os.path.join(self.params.outputs_dir, f"{file_name}.wav")
self.utils.save_audio(save_path, istft)

self.utils.graph_spectrogram(stft, "stft")
self.utils.graph_spectrogram(vis_istft, "post istft")
if visualize is True:
self.utils.graph_spectrogram(stft, "stft")
self.utils.graph_spectrogram(vis_istft, "post istft")

0 comments on commit 0f091e4

Please sign in to comment.