歌声合成:音频特征提取工具liborsa
liborsa 是一个用于音频特征提取的Python库,默认安装方式为 pip install librosa 并依赖于强大的ffmpeg工具处理音频文件。该库包含多个功能模块:librosa.beat 用于检测速度和节拍;librosa.core 用于加载音频并计算频谱图;librosa.decompose 实现谐波与冲击源分离;librosa.display 用于显示音频特征;librosa.effects 提供时域处理功能;librosa.feature 提供多种特征提取方法如色度图、MFCC等;librosa.filters 实现滤波器生成;librosa.onset 检测起始强度;librosa.segment 进行结构分段;以及辅助工具如规范化填充等。通过示例代码展示了如何使用这些功能模块进行 beat 跟踪、频谱分析及可视化结果展示(如图片:等)。
文章目录
- 音频特征提取工具liborsa
- source code
- show result
音频特征提取工具liborsa
pip install librosa
ffmpeg is very stronger.
librosa.beat:用于计算节奏信息
librosa.core:负责从音频文件加载数据并生成各种频谱表示
librosa.decompose:实现矩阵分解技术以实现调音器与其他通用频谱分解
librosa.display:提供音频特征可视化界面
librosa.effects:执行时域信号处理操作包括音高转换与时间尺度变换以及包装器功能
librosa.feature:提取音频特征及其相关操作如色度图、伪CQ变换、Mel频谱以及MFCC等
librosa.filters:设计滤波器以生成特定频率色度以及伪CQT等变换
librosa.onset:实现拍子检测与起始强度估计方法
librosa.segment:提供音频结构化分割函数
librosa.sequence:支持序列建模任务如序列分类与生成模型训练
source code
# -*- coding:utf-8 -*-
# /usr/bin/python
'''
@Author : Yan Errol
@Describe: 音频处理
@Evn : pip install librosa
@Date : 2019-08-04 15:23
'''
# Beat tracking example
#from __future__ import print_function
import librosa
# 1. Get the file path to the included audio example
filename = librosa.util.example_audio_file()
# 2. Load the audio as a waveform `y`
# Store the sampling rate as `sr`
filename = "../datasets/test.wav"
y, sr = librosa.load(filename)
print("y",y,"\nsr",sr)
# 3. Run the default beat tracker
tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr)
print("tempo",tempo, "\nbeat_frames",beat_frames)
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)
AI助手
show result




