def mel_sampling(
    audio, frame_duration_ms = 1200, overlap_ms = 200, sample_rate = 16000
):
    """
    Generates audio frames from audio. This is for melspectrogram generative model.
    Takes the desired frame duration in milliseconds, the audio, and the sample rate.

    Parameters
    ----------
    audio: np.array
    frame_duration_ms: int, optional (default=1200)
    overlap_ms: int, optional (default=200)
    sample_rate: int, optional (default=16000)

    Returns
    -------
    result: List[np.array]
    """

    n = int(sample_rate * (frame_duration_ms / 1000.0))
    n_overlap = int(sample_rate * (overlap_ms / 1000.0))
    offset = 0
    results = []
    while offset + n <= len(audio):
        results.append(audio[offset : offset + n])
        offset += n - n_overlap
    if offset < len(audio):
        results.append(audio[offset:])

    return results