import librosa
from scipy import signal


def extract_ltas(audio, fs=None, n_fft=1024, hop_length=256):
    """Extract Long-Term Average Spectrum for a given audio."""
    if fs != None:
        y, _ = librosa.load(audio, sr=fs)
    else:
        y, fs = librosa.load(audio)
    frequency, density = signal.welch(
        x=y, fs=fs, window="hann", nperseg=hop_length, nfft=n_fft
    )
    return frequency, density
