-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21a564d
commit 06a8dee
Showing
11 changed files
with
82 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
) | ||
from utils.signal_helpers import graph_spectrogram | ||
|
||
|
||
# Constants | ||
N_EPOCHS = 8 | ||
VALIDATION_INTERVAL = 4 | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import sys | ||
import os | ||
|
||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
|
||
|
||
import torch | ||
from architecture import Generator, LATENT_DIM | ||
from usage.usage_specs import ( | ||
model_to_generate_with, | ||
outputs_dir, | ||
generated_audio_name, | ||
audio_generation_count, | ||
visualize_generated, | ||
) | ||
from utils.file_helpers import get_device, save_audio | ||
from utils.signal_helpers import audio_to_norm_db, graph_spectrogram, norm_db_to_audio | ||
|
||
# Initialize Generator | ||
device = get_device() | ||
|
||
generator = Generator() | ||
generator.load_state_dict( | ||
torch.load( | ||
model_to_generate_with, map_location=torch.device(device), weights_only=False | ||
) | ||
) | ||
generator.eval() | ||
|
||
# Generate audio | ||
z = torch.randn(audio_generation_count, LATENT_DIM, 1, 1) | ||
with torch.no_grad(): | ||
generated_output = generator(z) | ||
|
||
|
||
generated_output = generated_output.squeeze().numpy() | ||
print("Generated output shape:", generated_output.shape) | ||
|
||
# Visualize and save audio | ||
for i in range(audio_generation_count): | ||
current_sample = generated_output[i] | ||
|
||
audio_info = norm_db_to_audio(current_sample) | ||
audio_save_path = os.path.join(outputs_dir, f"{generated_audio_name}-{i + 1}.wav") | ||
|
||
save_audio(audio_save_path, audio_info) | ||
|
||
if visualize_generated is True: | ||
vis_signal_after_istft = audio_to_norm_db(audio_info) | ||
graph_spectrogram(vis_signal_after_istft, "generated audio (after istft)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Processing training data | ||
training_audio_dir = "data/one_shots" # Your training data path | ||
compiled_data_path = "data/compiled_data.npy" # Your compiled data/output path | ||
training_sample_length = 0.6 # seconds | ||
|
||
# Saving model | ||
outputs_dir = "outputs" # Where to save your generated audio & model | ||
model_save_name = "StereoSampleGAN-OldKick" # What to name your model save | ||
model_save_path = f"{outputs_dir}/{model_save_name}.pth" | ||
|
||
# Generating audio | ||
model_to_generate_with = model_save_path # Generation model path | ||
audio_generation_count = 2 # Audio examples to generate | ||
generated_audio_name = "generated_audio" # Output file name | ||
generated_sample_length = 0.6 # Match model training data audio length | ||
visualize_generated = True # SHow generated audio spectrogra,s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters