    def audio_melspec(
        self, audio, n_mels=120, frame_size=320, hop_length=160, sr=16000, to_db=True
    ):
        """
        Compute the mel spectrogram of an audio signal.

        Args:
            audio (np.ndarray): Input audio signal.
            n_mels (int): Number of mel bands.
            frame_size (int): Size of the FFT window.
            hop_length (int): Number of samples between successive frames.
            sr (int): Sampling rate.
            to_db (bool): Whether to convert the power spectrogram to decibel units.

        Returns:
            np.ndarray: Mel spectrogram.
        """
        mel_spec = librosa.feature.melspectrogram(
            y=audio, sr=sr, n_fft=frame_size + 1, hop_length=hop_length, n_mels=n_mels
        )
        if to_db:
            mel_spec = (librosa.power_to_db(mel_spec, ref=np.max) + 40) / 40
        return mel_spec.T
Compute the mel spectrogram of an audio signal.

Args:
audio (np.ndarray): Input audio signal.
n_mels (int): Number of mel bands.
frame_size (int): Size of the FFT window.
hop_length (int): Number of samples between successive frames.
sr (int): Sampling rate.
to_db (bool): Whether to convert the power spectrogram to decibel units.

Returns:
np.ndarray: Mel spectrogram.
preprocessors/Emilia/models/dnsmos.py