通过librosa分析音乐获取节拍的时间轴数据,代码如下:
import librosa
import numpy as np
# 加载音频文件
y, sr = librosa.load('music.mp3')
# 检测节拍
tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr)
# 将帧转换为时间
#beat_times = librosa.frames_to_time(beat_frames, sr=sr)
beat_times = np.round(librosa.frames_to_time(beat_frames, sr=sr), decimals=2)
print(f"Estimated tempo: {tempo}")
print("Beat times:")
print(beat_times)
# 检测音乐起始点
onset_env = librosa.onset.onset_strength(y=y, sr=sr)
onset_frames = librosa.onset.onset_detect(onset_envelope=onset_env, sr=sr)
onset_times = librosa.frames_to_time(onset_frames, sr=sr)
print("Onset times:")
print(onset_times)
网友回复
有没有哪个大模型可以根据声音和文字描述生成带声音的视频?
如何实现华为手机终端设备之间隔空握拳抓取传送信息?
WinUI3和Electron有啥不同?
有哪些版权中心可以合作发布短剧漫剧进行赚钱?
ai装修解压视频提示词如何写?
有哪些视频钩子可以解决5s完播低问题?
seedance2如何根据一张九宫格分镜头图片生成ai视频短剧?
www.gstatic.com打开报错net::ERR_TUNNEL_CONNECTION_FAILED
果蝇大脑神经在计算机中复原意味人脑神经和意识也可在计算机中复原?
cosyvoice-v3.5声音克隆报错:Error during speech synthesis: start speech synthesizer failed within 5s.


