[Librosa] music/audio processing library Librosa 사용법 Tutorial - (1) install, import and load
Librosa는 music/audio data의 처리를 위해 사용되는 library이다.
이번학기 수업에서 사용하게 되어 사용법을 정리해보려고 한다.
Official docs: https://librosa.org/doc/main/index.html
librosa — librosa 0.8.1 documentation
© Copyright 2013--2021, librosa development team.
librosa.org
music/audio processing library Librosa 사용법 Tutorial
(1) Install, import and load
(2) Audio data representations (Spectogram, Mel-spectogram)
Install & Load librosa
다음과 같이 librosa library를 설치하고, 불러올 수 있다.
pip install librosa
import librosa
Load audio file
다음과 같이 audio file을 불러올 수 있다.
librosa에서 제공하는 example audio file을 사용해도 되고, 직접 audio file을 불러와도 된다.
filename = librosa.exampe('nutcracker')
y, sr = librosa.load(filename)
example audio file들은 아래 링크에서 확인할 수 있다.
https://librosa.org/doc/main/recordings.html
Example files — librosa 0.8.1 documentation
Example files librosa includes a small selection of example recordings which are primarily used to demonstrate different functions of the library. Beginning with version 0.8, these examples are automatically retrieved from a remote server upon request. Exa
librosa.org
librosa.load
method는 audio file에서 waveform y
와 sampling rate sr
을 불러온다.y
는 1차원 numpy float array이다.sr
은 초당 sample의 수를 의미하며, default 값은 22050Hz이다.
load method에 argument를 추가해 sampling rate를 재설정할 수도 있다.
librosa.display
를 이용하면 waveform을 시각화할 수 있다.
import librosa.display
librosa.display.waveplot(y, sr=sr)