- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
首先,该功能是消除音频的静音。这是官方的说明:
https://librosa.github.io/librosa/generated/librosa.effects.split.html
librosa.effects.split(y, top_db=10, *kargs)
Split an audio signal into non-silent intervals.
top_db:number > 0 The threshold (in decibels) below reference to consider as silence
return: intervals:np.ndarray, shape=(m, 2) intervals[i] == (start_i, end_i) are the start and end time (in samples) of non-silent interval i.
所以这非常简单,对于任何低于 10dB 的声音,将其视为静音并从音频中删除。它将返回给我一个间隔列表,这些间隔是音频中的非静音片段。
所以我做了一个非常简单的例子,结果让我感到困惑:我在这里加载的音频是 3 秒的人类说话,非常正常的说话。
y, sr = librosa.load(file_list[0]) #load the data
print(y.shape) -> (87495,)
intervals = librosa.effects.split(y, top_db=100)
intervals -> array([[0, 87495]])
#if i change 100 to 10
intervals = librosa.effects.split(y, top_db=10)
intervals -> array([[19456, 23040],
[27136, 31232],
[55296, 58880],
[64512, 67072]])
这怎么可能......
我告诉 librosa,好吧,对于任何低于 100dB 的声音,将其视为静音。在这个设置下,整个音频应该被视为静音,并且根据文档,它应该给我 array[[0,0]] 一些东西......因为删除静音后,什么都没有留下......
但 librosa 似乎返回给我的是沉默部分而不是非沉默部分。
最佳答案
librosa.effects.split()
它在文档中说它返回一个 numpy 数组,其中包含包含非静音音频的间隔。当然,这些间隔取决于您分配给参数 top_db
的值。 它不返回任何音频,只返回波形非静音片段的起点和终点
在您的情况下,即使您设置 top_db = 100,它也不会将整个音频视为静音,因为它们在文档中声明它们使用引用功率。默认情况下,它使用 **np.max** 并与信号中的峰值功率进行比较。
因此,将 top_db 设置为高于音频中存在的最大值实际上会导致 top_db 没有任何效果。这是一个例子:
import librosa
import numpy as np
import matplotlib.pyplot as plt
# create a hypothetical waveform with 1000 noisy samples and 1000 silent samples
nonsilent = np.random.randint(11, 100, 1000) * 100
silent = np.zeros(1000)
wave = np.concatenate((nonsilent, silent))
# look at it
print(wave.shape)
plt.plot(wave)
plt.show()
# get the noisy interval
non_silent_interval = librosa.effects.split(wave, top_db=0.1, hop_length=1000)
print(non_silent_interval)
# plot only the noisy chunk of the waveform
plt.plot(wave[non_silent_interval[0][0]:non_silent_interval[0][1]])
plt.show()
# now set top_db higher than anything in your audio
non_silent_interval = librosa.effects.split(wave, top_db=1000, hop_length=1000)
print(non_silent_interval)
# and you'll get the entire audio again
plt.plot(wave[non_silent_interval[0][0]:non_silent_interval[0][1]])
plt.show()
您可以看到非静音音频是从0到1000,静音音频是从1000到2000个样本:
这意味着 librosa 做了它在文档中 promise 的所有事情。希望这会有所帮助。
关于python - 我认为 Librosa.effect.split 有问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58841039/
我正在尝试使用 librosa 通过从持续时间为 60 秒的某个 .wav 文件中剪切 1 秒的片段来生成一些数据。 这部分有效,我创建了所有文件,我也可以通过任何播放器收听它们,但是如果我尝试使用
有一个代码可以为单声道音频生成梅尔谱图。 import librosa, librosa.display import matplotlib.pyplot as plt import numpy as
有没有可以让我选择传递给MFCC算法的频带的API? 假设我有2个不同的麦克风,每个麦克风都有不同的频率范围,一个为0〜12000Hz,另一个为0〜20000Hz 显然,即使在录制以节省声源时,第一和
我是信号处理的新手,并且正在使用librosa库。 我想知道当我使用librosa.load函数读取音频(.wav)文件时返回的信息是什么。 是pa中的瞬时声压吗?还是只是声音信号的瞬时幅度没有单位?
所以我试图让 librosa 使用麦克风输入,而不仅仅是 wav 文件,并且遇到了一些问题。最初我使用 pyaudio 库连接到麦克风,但我在翻译这些数据以供 librosa 使用时遇到了问题。关于如
Librosa Python 3.5在 8000Hhz 音频样本上出现错误: extract feature error. Filter pass-band lies beyond Nyquist 之
所以我在 IPython 中使用 librosa 库,到目前为止没有遇到任何问题,直到昨天未能导入它。特别是当我尝试导入 librosa 时,它会给我以下错误消息。 import librosa Im
当使用库 Librosa 在 16 位 44.1 khz 音频文件上执行 STFT,然后执行逆 STFT (iSTFT) 时: import librosa y, sr = librosa.load(
我正在尝试绘制 16000Hz 16 位 .wav 语音音频的波形图和频谱图。我已成功获得以下地 block : 但是,频谱图上的时间值不正确。我确定我的采样率在整个程序中是一致的 (16000Hz)
我正在使用 native beat_track来自 Librosa 的函数: from librosa.beat import beat_track tempo, beat_frames = beat
除非我使用 librosa 之一'.ogg' 格式的 native '示例'音频文件,我无法加载音频。 每个 github 问题和 SO 答案都说我需要安装 ffmpeg。我找到了一个名为 ffmpe
我有点难以理解 MFCC。 从我读到的 mel 滤波器组应该是一系列三角形,它们变得更宽并且它们的峰值在同一个地方。像这样... 但是,当我使用 librosa 计算 mel 滤波器组时,我得到...
我目前正在尝试使用 librosa 来执行 stfft,这样参数类似于来自不同框架 (Kaldi) 的 stfft 进程。 音频文件是 fash-b-an251 Kaldi 使用 16 KHz 的采样
我的python版本是3.7.4,而Librosa版本是0.8.0下面是我的代码: import librosa import librosa.display import matplotlib.py
我正在尝试隔离音频流的前景,然后使用 librosa 将其保存为独立的音频流。 从这个看似开始relevant example . 我有完整的前景和背景数据,就像 S_full 中的例子一样。 , S
在 AudioSegment来自 from pydub import AudioSegment ,有一个函数set_sample_width .从文档: Creates an equivalent v
我将一些音频文件转换为频谱图并使用以下代码将它们保存到文件中: import os from matplotlib import pyplot as plt import librosa import
所以我想将频谱图图像提供给卷积神经网络,以尝试对各种声音进行分类。我希望每个图像都是 384x128 像素。但是,当我实际保存图像时,它只有 297x98。这是我的代码: def save_spect
我想提取以 8000 Hz 采样、帧大小为 20 毫秒和 10 毫秒重叠的音频文件的 mfcc 特征。 librosa.feature.mfcc() 函数的参数必须是什么。下面编写的代码是否指定了具有
我想提取以 8000 Hz 采样、帧大小为 20 毫秒和 10 毫秒重叠的音频文件的 mfcc 特征。 librosa.feature.mfcc() 函数的参数必须是什么。下面编写的代码是否指定了具有
我是一名优秀的程序员,十分优秀!