def down_sample(sound, sample_rate_out):
    """Downsample audio
    Args:
        sound (pydub.AudioSegment): Sound imported as a AudioSegment object
        sample_rate_out (int): Final sample rate for output data

    Returns:
        pydub.AudioSegment: Downsampled audio
    """    

    # Manually override the frame_rate. This tells the computer how many
    # samples to play per second
    sound_with_altered_frame_rate = sound._spawn(sound.raw_data, overrides={
        "frame_rate": int(sound.frame_rate)
    })

    # Convert the sound with altered frame rate to a standard frame rate
    # so that regular playback programs will work right. 
    return sound_with_altered_frame_rate.set_frame_rate(sample_rate_out)