switched to gan and train.py.
This commit is contained in:
10
data.py
10
data.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user