switched to gan and train.py.

This commit is contained in:
k
2025-09-05 14:38:45 -04:00
parent 5df1e5df7e
commit ccc3fa3ed4
4 changed files with 147 additions and 83 deletions

10
data.py
View File

@@ -2,15 +2,17 @@ import librosa
import numpy as np
from pathlib import Path
from multiprocessing import Pool, cpu_count
import mlflow
SAMPLE_RATE = 22050
@mlflow.trace
def process_file(file_path):
"""
Load 10 second chunks single song.
"""
y, sr = librosa.load(file_path, mono=True, sr=SAMPLE_RATE)
size = int(SAMPLE_RATE * 10)
size = int(SAMPLE_RATE * 5)
sample_len = len(y)
file_chunks = []
@@ -18,9 +20,12 @@ def process_file(file_path):
end = start_pos + size
if end <= sample_len:
chunk = y[start_pos:end]
chunk = librosa.feature.melspectrogram(y=chunk,sr=SAMPLE_RATE)
chunk = ((librosa.amplitude_to_db(chunk,ref=np.max)+40)/40)
file_chunks.append(chunk)
return file_chunks
@mlflow.trace
def load():
"""
Load 10 second chunks of songs.
@@ -33,6 +38,9 @@ def load():
audio.extend(l)
return audio
##DEP
def audio_split(audio):
"""
Split 10 seconds of audio to 2 5 second clips