Fork me on GitHub

一 概念
librosa是一个用于音乐和音频分析的python包。它提供了创建音乐信息检索系统所需的构建块。
核心函数:
 
二 实例解析
 
实例A,确认是否安装成功:
import librosa

print(librosa.__version__)

 

如运行成功,说明安装成功的。
接下来测试基本功能,提取beat:
# Beat tracking example
import librosa

# 1. Get the file path to an included audio example
filename = librosa.example('nutcracker')


# 2. Load the audio as a waveform `y`
#    Store the sampling rate as `sr`
y, sr = librosa.load(filename)

# 3. Run the default beat tracker
tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr)

print('Estimated tempo: {:.2f} beats per minute'.format(tempo))

# 4. Convert the frame indices of beat events into timestamps
beat_times = librosa.frames_to_time(beat_frames, sr=sr)
print(beat_times)

 

三 总结备忘
 
1.关于安装:
一般使用pip先安装会失败,遇到这种情况,确认是否有一些库无法导致。假如是,解决方案:
先把这个库下载然后安装,或者切换源。

 

四 参考文档
 
posted on 2022-05-03 20:54  虚生  阅读(361)  评论(0编辑  收藏  举报