# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import torch 
import torch.nn as nn
import torchvision.datasets as dsets
import torchvision.transforms as transforms
from torch.autograd import Variable
import librosa
import librosa.display
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pylab

from IPython.display import Audio, display
import matplotlib.pyplot as plt

import numpy as np
import pydub
# -

songname ="2.216.326.930-Major Lazer & DJ Snake - Lean On (feat. MÃ_) (Official Music Video)"


y, sr = librosa.load('/Users/ilayda/Music/Audios/HIGH/'+songname+'.mp3', mono=True, duration=120, sr=None)

y.shape, sr

librosa.core.get_duration(y, sr)

S = librosa.feature.melspectrogram(y=y, n_mels=128*4, fmax=8000)
plt.figure(figsize=(10,4))
librosa.display.specshow(librosa.power_to_db(S, ref=np.max), 
                        y_axis='mel', fmax=8000, 
                        x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('Mel spectrogram')
plt.tight_layout()
plt.show()
S.shape

df = pd.DataFrame(S)
df.describe()

librosa.output.write_wav(y=y, sr=sr, path='/Users/ilayda/Music/Audios/HIGH/wavfiles/'+songname+'.wav')

StarcoderdataJupyterScriptsDedupFiltered