File size: 204 Bytes
60dc67b
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
import librosa
import soundfile as sf


def compress(audio_file):
    y, s = librosa.load(audio_file, sr=8000)  # Downsample 44.1kHz to 8kHz
    sf.write(audio_file, y, s, "PCM_24")
    return audio_file